Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.h
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
//! 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 initMessages() and showProgress() methods which the wallet uses to | ||||
//! should be removed when clients are able to respond to updates | //! send | ||||
//! asynchronously | |||||
//! (https://github.com/bitcoin/bitcoin/pull/10973#issuecomment-380101269). | |||||
//! | |||||
//! * The initMessage() and showProgress() 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). | ||||
//! | //! | ||||
//! * The handleRpc, registerRpcs, rpcEnableDeprecated methods and other RPC | //! * The handleRpc, registerRpcs, rpcEnableDeprecated methods and other RPC | ||||
//! methods can go away if wallets listen for HTTP requests on their own | //! methods can go away if wallets listen for HTTP requests on their own | ||||
//! ports instead of registering to handle requests on the node HTTP port. | //! ports instead of registering to handle requests on the node HTTP port. | ||||
//! | |||||
//! * Move fee estimation queries to an asynchronous interface and let the | |||||
//! wallet cache it, fee estimation being driven by node mempool, wallet | |||||
//! should be the consumer. | |||||
//! | |||||
//! * The `guessVerificationProgress`, `getBlockHeight`, `getBlockHash`, etc | |||||
//! methods can go away if rescan logic is moved on the node side, and wallet | |||||
//! only register rescan request. | |||||
class Chain { | class Chain { | ||||
public: | public: | ||||
virtual ~Chain() {} | virtual ~Chain() {} | ||||
//! Interface for querying locked chain state, used by legacy code that | |||||
//! assumes state won't change between calls. New code should avoid using | |||||
//! the Lock interface and instead call higher-level Chain methods | |||||
//! that return more information so the chain doesn't need to stay locked | |||||
//! between calls. | |||||
class Lock { | |||||
public: | |||||
virtual ~Lock() {} | |||||
}; | |||||
//! Return Lock interface. Chain is locked when this is called, and | |||||
//! unlocked when the returned interface is freed. | |||||
virtual std::unique_ptr<Lock> lock(bool try_lock = false) = 0; | |||||
//! Get current chain height, not including genesis block (returns 0 if | //! Get current chain height, not including genesis block (returns 0 if | ||||
//! chain only contains genesis block, nullopt if chain does not contain | //! chain only contains genesis block, nullopt if chain does not contain | ||||
//! any blocks) | //! any blocks) | ||||
virtual Optional<int> getHeight() = 0; | virtual Optional<int> getHeight() = 0; | ||||
//! Get block height above genesis block. Returns 0 for genesis block, | //! Get block height above genesis block. Returns 0 for genesis block, | ||||
//! 1 for following block, and so on. Returns nullopt for a block not | //! 1 for following block, and so on. Returns nullopt for a block not | ||||
//! included in the current chain. | //! included in the current chain. | ||||
▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines |