Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.h
Show All 22 Lines | |||||
class CScheduler; | class CScheduler; | ||||
class CValidationState; | class CValidationState; | ||||
namespace Consensus { | namespace Consensus { | ||||
struct Params; | struct Params; | ||||
} | } | ||||
namespace interfaces { | namespace interfaces { | ||||
class Handler; | |||||
class Wallet; | class Wallet; | ||||
//! Interface giving clients (wallet processes, maybe other analysis tools in | //! Interface giving clients (wallet processes, maybe other analysis tools in | ||||
//! the future) ability to access to the chain state, receive notifications, | //! the future) ability to access to the chain state, receive notifications, | ||||
//! estimate fees, and submit transactions. | //! estimate fees, and submit transactions. | ||||
//! | //! | ||||
//! TODO: Current chain methods are too low level, exposing too much of the | //! TODO: Current chain methods are too low level, exposing too much of the | ||||
//! internal workings of the bitcoin node, and not being very convenient to use. | //! internal workings of the bitcoin node, and not being very convenient to use. | ||||
//! Chain methods should be cleaned up and simplified over time. Examples: | //! Chain methods should be cleaned up and simplified over time. Examples: | ||||
//! | //! | ||||
//! * The Chain::lock() method, which lets clients delay chain tip updates | //! * The Chain::lock() method, which lets clients delay chain tip updates | ||||
//! should be removed when clients are able to respond to updates | //! should be removed when clients are able to respond to updates | ||||
//! asynchronously | //! asynchronously | ||||
//! (https://github.com/bitcoin/bitcoin/pull/10973#issuecomment-380101269). | //! (https://github.com/bitcoin/bitcoin/pull/10973#issuecomment-380101269). | ||||
//! | //! | ||||
//! * The isPotentialTip() and waitForNotifications() methods are too low-level | |||||
//! and should be replaced with a higher level | |||||
//! waitForNotificationsUpTo(block_hash) method that the wallet can call | |||||
//! instead | |||||
//! (https://github.com/bitcoin/bitcoin/pull/10973#discussion_r266995234). | |||||
//! | |||||
//! * The relayTransactions() and submitToMemoryPool() methods could be replaced | //! * The relayTransactions() and submitToMemoryPool() methods could be replaced | ||||
//! with a higher-level broadcastTransaction method | //! with a higher-level broadcastTransaction method | ||||
//! (https://github.com/bitcoin/bitcoin/pull/14978#issuecomment-459373984). | //! (https://github.com/bitcoin/bitcoin/pull/14978#issuecomment-459373984). | ||||
//! | //! | ||||
//! * The initMessages() and loadWallet() methods which the wallet uses to send | //! * The initMessages() and loadWallet() methods which the wallet uses to send | ||||
//! notifications to the GUI should go away when GUI and wallet can directly | //! notifications to the GUI should go away when GUI and wallet can directly | ||||
//! communicate with each other without going through the node | //! communicate with each other without going through the node | ||||
//! (https://github.com/bitcoin/bitcoin/pull/15288#discussion_r253321096). | //! (https://github.com/bitcoin/bitcoin/pull/15288#discussion_r253321096). | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | public: | ||||
//! Send init warning. | //! Send init warning. | ||||
virtual void initWarning(const std::string &message) = 0; | virtual void initWarning(const std::string &message) = 0; | ||||
//! Send init error. | //! Send init error. | ||||
virtual void initError(const std::string &message) = 0; | virtual void initError(const std::string &message) = 0; | ||||
//! Send wallet load notification to the GUI. | //! Send wallet load notification to the GUI. | ||||
virtual void loadWallet(std::unique_ptr<Wallet> wallet) = 0; | virtual void loadWallet(std::unique_ptr<Wallet> wallet) = 0; | ||||
//! Chain notifications. | |||||
class Notifications { | |||||
public: | |||||
virtual ~Notifications() {} | |||||
virtual void TransactionAddedToMempool(const CTransactionRef &tx) {} | |||||
virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) { | |||||
} | |||||
virtual void | |||||
BlockConnected(const CBlock &block, | |||||
const std::vector<CTransactionRef> &tx_conflicted) {} | |||||
virtual void BlockDisconnected(const CBlock &block) {} | |||||
virtual void ChainStateFlushed(const CBlockLocator &locator) {} | |||||
virtual void ResendWalletTransactions(Lock &locked_chain, | |||||
int64_t best_block_time) {} | |||||
}; | |||||
//! Register handler for notifications. | |||||
virtual std::unique_ptr<Handler> | |||||
handleNotifications(Notifications ¬ifications) = 0; | |||||
//! Wait for pending notifications to be handled. | |||||
virtual void waitForNotifications() = 0; | |||||
}; | }; | ||||
//! Interface to let node manage chain clients (wallets, or maybe tools for | //! Interface to let node manage chain clients (wallets, or maybe tools for | ||||
//! monitoring and analysis in the future). | //! monitoring and analysis in the future). | ||||
class ChainClient { | class ChainClient { | ||||
public: | public: | ||||
virtual ~ChainClient() {} | virtual ~ChainClient() {} | ||||
Show All 36 Lines |