2014-04-07 15:02:15 +00:00
|
|
|
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "cryptonote_core/cryptonote_basic.h"
|
|
|
|
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
|
|
|
#include "rpc/core_rpc_server_commands_defs.h"
|
2014-04-07 15:02:15 +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) {}
|
2014-06-25 17:21:42 +00:00
|
|
|
virtual void localBlockchainUpdated(uint64_t height) {}
|
2014-04-07 15:02:15 +00:00
|
|
|
virtual void lastKnownBlockHeightUpdated(uint64_t height) {}
|
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 {
|
|
|
|
uint64_t outGlobalIndex;
|
|
|
|
crypto::public_key outKey;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OutsForAmount {
|
|
|
|
uint64_t amount;
|
|
|
|
std::vector<OutEntry> outs;
|
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;
|
|
|
|
virtual uint64_t getLastLocalBlockHeight() const = 0;
|
|
|
|
virtual uint64_t getLastKnownBlockHeight() const = 0;
|
2014-04-09 12:14:35 +00:00
|
|
|
|
2014-06-25 17:21:42 +00:00
|
|
|
virtual void relayTransaction(const cryptonote::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;
|
|
|
|
virtual void getNewBlocks(std::list<crypto::hash>&& knownBlockIds, std::list<cryptonote::block_complete_entry>& newBlocks, uint64_t& startHeight, const Callback& callback) = 0;
|
|
|
|
virtual void getTransactionOutsGlobalIndices(const crypto::hash& transactionHash, std::vector<uint64_t>& outsGlobalIndices, const Callback& callback) = 0;
|
2014-04-07 15:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|