danicoin/src/wallet/WalletUserTransactionsCache.h

83 lines
3.1 KiB
C
Raw Normal View History

2015-05-27 12:08:46 +00:00
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
2014-08-13 10:38:35 +00:00
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
2014-06-25 17:21:42 +00:00
#pragma once
#include "crypto/hash.h"
#include "IWallet.h"
#include "ITransfersContainer.h"
#include "WalletEvent.h"
#include "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:
WalletUserTransactionsCache() {}
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;
TransactionId addNewTransaction(uint64_t amount, uint64_t fee, const std::string& extra, const std::vector<Transfer>& 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);
std::shared_ptr<WalletEvent> onTransactionUpdated(const TransactionInformation& txInfo, int64_t txBalance);
std::shared_ptr<WalletEvent> onTransactionDeleted(const TransactionHash& transactionHash);
2014-06-25 17:21:42 +00:00
TransactionId findTransactionByTransferId(TransferId transferId) const;
2014-08-13 10:51:37 +00:00
bool getTransaction(TransactionId transactionId, TransactionInfo& transaction) const;
TransactionInfo& getTransaction(TransactionId transactionId);
2014-06-25 17:21:42 +00:00
bool getTransfer(TransferId transferId, Transfer& transfer) const;
Transfer& getTransfer(TransferId transferId);
bool isUsed(const TransactionOutputInformation& out) const;
2015-07-09 14:52:47 +00:00
void reset();
private:
TransactionId findTransactionByHash(const TransactionHash& hash);
2014-08-13 10:51:37 +00:00
TransactionId insertTransaction(TransactionInfo&& Transaction);
2014-06-25 17:21:42 +00:00
TransferId insertTransfers(const std::vector<Transfer>& transfers);
void updateUnconfirmedTransactions();
2014-06-25 17:21:42 +00:00
typedef std::vector<Transfer> UserTransfers;
2014-08-13 10:51:37 +00:00
typedef std::vector<TransactionInfo> 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