Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.h
Show All 34 Lines | |||||
enum class SynchronizationState; | enum class SynchronizationState; | ||||
class UniValue; | class UniValue; | ||||
enum class WalletCreationStatus; | enum class WalletCreationStatus; | ||||
struct bilingual_str; | struct bilingual_str; | ||||
namespace interfaces { | namespace interfaces { | ||||
class Handler; | class Handler; | ||||
class Wallet; | class Wallet; | ||||
struct BlockTip; | |||||
//! Top-level interface for a bitcoin node (bitcoind process). | //! Top-level interface for a bitcoin node (bitcoind process). | ||||
class Node { | class Node { | ||||
public: | public: | ||||
virtual ~Node() {} | virtual ~Node() {} | ||||
//! Init logging. | //! Init logging. | ||||
virtual void initLogging() = 0; | virtual void initLogging() = 0; | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | public: | ||||
handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0; | handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0; | ||||
//! Register handler for ban list messages. | //! Register handler for ban list messages. | ||||
using BannedListChangedFn = std::function<void()>; | using BannedListChangedFn = std::function<void()>; | ||||
virtual std::unique_ptr<Handler> | virtual std::unique_ptr<Handler> | ||||
handleBannedListChanged(BannedListChangedFn fn) = 0; | handleBannedListChanged(BannedListChangedFn fn) = 0; | ||||
//! Register handler for block tip messages. | //! Register handler for block tip messages. | ||||
using NotifyBlockTipFn = std::function<void( | using NotifyBlockTipFn = | ||||
SynchronizationState, const BlockHash &block_hash, int height, | std::function<void(SynchronizationState, interfaces::BlockTip tip, | ||||
int64_t block_time, double verification_progress)>; | double verification_progress)>; | ||||
virtual std::unique_ptr<Handler> | virtual std::unique_ptr<Handler> | ||||
handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; | handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; | ||||
//! Register handler for header tip messages. | //! Register handler for header tip messages. | ||||
using NotifyHeaderTipFn = std::function<void( | using NotifyHeaderTipFn = | ||||
SynchronizationState, const BlockHash &block_hash, int height, | std::function<void(SynchronizationState, interfaces::BlockTip tip, | ||||
int64_t block_time, double verification_progress)>; | double verification_progress)>; | ||||
virtual std::unique_ptr<Handler> | virtual std::unique_ptr<Handler> | ||||
handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; | handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; | ||||
//! Get and set internal node context. Useful for testing, but not | //! Get and set internal node context. Useful for testing, but not | ||||
//! accessible across processes. | //! accessible across processes. | ||||
virtual NodeContext *context() { return nullptr; } | virtual NodeContext *context() { return nullptr; } | ||||
virtual void setContext(NodeContext *context) {} | virtual void setContext(NodeContext *context) {} | ||||
}; | }; | ||||
//! Return implementation of Node interface. | //! Return implementation of Node interface. | ||||
std::unique_ptr<Node> MakeNode(NodeContext *context = nullptr); | std::unique_ptr<Node> MakeNode(NodeContext *context = nullptr); | ||||
//! Block tip (could be a header or not, depends on the subscribed signal). | |||||
struct BlockTip { | |||||
int block_height; | |||||
int64_t block_time; | |||||
BlockHash block_hash; | |||||
}; | |||||
} // namespace interfaces | } // namespace interfaces | ||||
#endif // BITCOIN_INTERFACES_NODE_H | #endif // BITCOIN_INTERFACES_NODE_H |