danicoin/include/INode.h

103 lines
4.7 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-04-07 15:02:15 +00:00
#pragma once
#include <cstdint>
2014-06-25 17:21:42 +00:00
#include <functional>
2014-04-07 15:02:15 +00:00
#include <system_error>
2014-06-25 17:21:42 +00:00
#include <vector>
#include "crypto/crypto.h"
2015-07-30 15:22:07 +00:00
#include "CryptoNoteCore/CryptoNoteBasic.h"
#include "CryptoNoteProtocol/CryptoNoteProtocolDefinitions.h"
#include "Rpc/CoreRpcServerCommandsDefinitions.h"
2014-04-07 15:02:15 +00:00
2015-07-15 12:23:00 +00:00
#include "BlockchainExplorerData.h"
2015-07-30 15:22:07 +00:00
#include "ITransaction.h"
2015-07-15 12:23:00 +00:00
2014-04-09 12:14:35 +00:00
namespace CryptoNote {
2014-04-07 15:02:15 +00:00
class INodeObserver {
public:
2014-06-25 17:21:42 +00:00
virtual ~INodeObserver() {}
2014-04-07 15:02:15 +00:00
virtual void peerCountUpdated(size_t count) {}
2015-07-30 15:22:07 +00:00
virtual void localBlockchainUpdated(uint32_t height) {}
virtual void lastKnownBlockHeightUpdated(uint32_t height) {}
virtual void poolChanged() {}
2015-07-30 15:22:07 +00:00
virtual void blockchainSynchronized(uint32_t topHeight) {}
2014-06-25 17:21:42 +00:00
};
2014-04-07 15:02:15 +00:00
2014-06-25 17:21:42 +00:00
struct OutEntry {
2015-07-30 15:22:07 +00:00
uint32_t outGlobalIndex;
Crypto::PublicKey outKey;
2014-06-25 17:21:42 +00:00
};
struct OutsForAmount {
uint64_t amount;
std::vector<OutEntry> outs;
2014-04-07 15:02:15 +00:00
};
2015-07-30 15:22:07 +00:00
struct TransactionShortInfo {
Crypto::Hash txId;
TransactionPrefix txPrefix;
};
struct BlockShortEntry {
Crypto::Hash blockHash;
bool hasBlock;
CryptoNote::Block block;
std::vector<TransactionShortInfo> txsShortInfo;
};
2014-04-07 15:02:15 +00:00
class INode {
public:
2014-06-25 17:21:42 +00:00
typedef std::function<void(std::error_code)> Callback;
virtual ~INode() {}
virtual bool addObserver(INodeObserver* observer) = 0;
virtual bool removeObserver(INodeObserver* observer) = 0;
virtual void init(const Callback& callback) = 0;
virtual bool shutdown() = 0;
2014-04-07 15:02:15 +00:00
2014-06-25 17:21:42 +00:00
virtual size_t getPeerCount() const = 0;
2015-07-30 15:22:07 +00:00
virtual uint32_t getLastLocalBlockHeight() const = 0;
virtual uint32_t getLastKnownBlockHeight() const = 0;
virtual uint32_t getLocalBlockCount() const = 0;
virtual uint32_t getKnownBlockCount() const = 0;
virtual uint64_t getLastLocalBlockTimestamp() const = 0;
2014-04-09 12:14:35 +00:00
2015-05-27 12:08:46 +00:00
virtual void relayTransaction(const Transaction& transaction, const Callback& callback) = 0;
virtual void getRandomOutsByAmounts(std::vector<uint64_t>&& amounts, uint64_t outsCount, std::vector<CryptoNote::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount>& result, const Callback& callback) = 0;
2015-07-30 15:22:07 +00:00
virtual void getNewBlocks(std::vector<Crypto::Hash>&& knownBlockIds, std::vector<CryptoNote::block_complete_entry>& newBlocks, uint32_t& startHeight, const Callback& callback) = 0;
virtual void getTransactionOutsGlobalIndices(const Crypto::Hash& transactionHash, std::vector<uint32_t>& outsGlobalIndices, const Callback& callback) = 0;
virtual void queryBlocks(std::vector<Crypto::Hash>&& knownBlockIds, uint64_t timestamp, std::vector<BlockShortEntry>& newBlocks, uint32_t& startHeight, const Callback& callback) = 0;
virtual void getPoolSymmetricDifference(std::vector<Crypto::Hash>&& knownPoolTxIds, Crypto::Hash knownBlockId, bool& isBcActual, std::vector<std::unique_ptr<ITransactionReader>>& newTxs, std::vector<Crypto::Hash>& deletedTxIds, const Callback& callback) = 0;
virtual void getMultisignatureOutputByGlobalIndex(uint64_t amount, uint32_t gindex, MultisignatureOutput& out, const Callback& callback) = 0;
virtual void getBlocks(const std::vector<uint32_t>& blockHeights, std::vector<std::vector<BlockDetails>>& blocks, const Callback& callback) = 0;
virtual void getBlocks(const std::vector<Crypto::Hash>& blockHashes, std::vector<BlockDetails>& blocks, const Callback& callback) = 0;
virtual void getBlocks(uint64_t timestampBegin, uint64_t timestampEnd, uint32_t blocksNumberLimit, std::vector<BlockDetails>& blocks, uint32_t& blocksNumberWithinTimestamps, const Callback& callback) = 0;
virtual void getTransactions(const std::vector<Crypto::Hash>& transactionHashes, std::vector<TransactionDetails>& transactions, const Callback& callback) = 0;
virtual void getTransactionsByPaymentId(const Crypto::Hash& paymentId, std::vector<TransactionDetails>& transactions, const Callback& callback) = 0;
virtual void getPoolTransactions(uint64_t timestampBegin, uint64_t timestampEnd, uint32_t transactionsNumberLimit, std::vector<TransactionDetails>& transactions, uint64_t& transactionsNumberWithinTimestamps, const Callback& callback) = 0;
2015-07-15 12:23:00 +00:00
virtual void isSynchronized(bool& syncStatus, const Callback& callback) = 0;
2014-04-07 15:02:15 +00:00
};
}