danicoin/src/WalletLegacy/WalletUserTransactionsCache.h

72 lines
2.7 KiB
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-06-25 17:21:42 +00:00
#pragma once
#include "crypto/hash.h"
2015-07-30 15:22:07 +00:00
#include "IWalletLegacy.h"
#include "ITransfersContainer.h"
2015-07-30 15:22:07 +00:00
#include "WalletLegacy/WalletLegacyEvent.h"
#include "WalletLegacy/WalletUnconfirmedTransactions.h"
2015-05-27 12:08:46 +00:00
namespace CryptoNote {
class ISerializer;
}
2014-06-25 17:21:42 +00:00
namespace CryptoNote {
class WalletUserTransactionsCache
{
public:
2015-08-05 13:09:05 +00:00
explicit WalletUserTransactionsCache(uint64_t mempoolTxLiveTime = 60 * 60 * 24);
2014-06-25 17:21:42 +00:00
2015-07-15 12:23:00 +00:00
bool serialize(CryptoNote::ISerializer& serializer);
2014-06-25 17:21:42 +00:00
uint64_t unconfirmedTransactionsAmount() const;
uint64_t unconfrimedOutsAmount() const;
2014-06-25 17:21:42 +00:00
size_t getTransactionCount() const;
size_t getTransferCount() const;
2015-07-30 15:22:07 +00:00
TransactionId addNewTransaction(uint64_t amount, uint64_t fee, const std::string& extra, const std::vector<WalletLegacyTransfer>& transfers, uint64_t unlockTime);
2015-05-27 12:08:46 +00:00
void updateTransaction(TransactionId transactionId, const CryptoNote::Transaction& tx, uint64_t amount, const std::list<TransactionOutputInformation>& usedOutputs);
void updateTransactionSendingState(TransactionId transactionId, std::error_code ec);
2015-07-30 15:22:07 +00:00
std::shared_ptr<WalletLegacyEvent> onTransactionUpdated(const TransactionInformation& txInfo, int64_t txBalance);
std::shared_ptr<WalletLegacyEvent> onTransactionDeleted(const Crypto::Hash& transactionHash);
2014-06-25 17:21:42 +00:00
TransactionId findTransactionByTransferId(TransferId transferId) const;
2015-07-30 15:22:07 +00:00
bool getTransaction(TransactionId transactionId, WalletLegacyTransaction& transaction) const;
WalletLegacyTransaction& getTransaction(TransactionId transactionId);
bool getTransfer(TransferId transferId, WalletLegacyTransfer& transfer) const;
WalletLegacyTransfer& getTransfer(TransferId transferId);
2014-06-25 17:21:42 +00:00
bool isUsed(const TransactionOutputInformation& out) const;
2015-07-09 14:52:47 +00:00
void reset();
2015-08-05 13:09:05 +00:00
std::vector<TransactionId> deleteOutdatedTransactions();
private:
2015-07-30 15:22:07 +00:00
TransactionId findTransactionByHash(const Crypto::Hash& hash);
TransactionId insertTransaction(WalletLegacyTransaction&& Transaction);
TransferId insertTransfers(const std::vector<WalletLegacyTransfer>& transfers);
void updateUnconfirmedTransactions();
2014-06-25 17:21:42 +00:00
2015-07-30 15:22:07 +00:00
typedef std::vector<WalletLegacyTransfer> UserTransfers;
typedef std::vector<WalletLegacyTransaction> UserTransactions;
2014-06-25 17:21:42 +00:00
void getGoodItems(UserTransactions& transactions, UserTransfers& transfers);
void getGoodTransaction(TransactionId txId, size_t offset, UserTransactions& transactions, UserTransfers& transfers);
2014-06-25 17:21:42 +00:00
void getTransfersByTx(TransactionId id, UserTransfers& transfers);
UserTransactions m_transactions;
UserTransfers m_transfers;
WalletUnconfirmedTransactions m_unconfirmedTransactions;
2014-06-25 17:21:42 +00:00
};
} //namespace CryptoNote