[−][src]Trait nakamoto_node::handle::Handle
A handle for communicating with a node process.
Associated Types
type Event
Node event generated during protocol operation.
type Message
The message payload exchanged between nodes in the network.
Required methods
fn get_tip(&self) -> Result<BlockHeader, Error>
Get the tip of the chain.
fn get_block(&self, hash: &BlockHash) -> Result<Block, Error>
Get a full block from the network.
fn connect(&self, addr: SocketAddr) -> Result<Link, Error>
Connect to the designated peer address.
fn submit_transaction(&self, tx: Transaction) -> Result<(), Error>
Submit a transaction to the network.
fn import_headers(
&self,
headers: Vec<BlockHeader>
) -> Result<Result<ImportResult, Error>, Error>
&self,
headers: Vec<BlockHeader>
) -> Result<Result<ImportResult, Error>, Error>
Import block headers into the node. This may cause the node to broadcast header or inventory messages to its peers.
fn receive(&self, from: SocketAddr, msg: Self::Message) -> Result<(), Error>
Have the node receive a message as if it was coming from the given peer in the network. If the peer is not connected, the message is ignored.
fn wait<F: Fn(Self::Event) -> Option<T>, T>(&self, f: F) -> Result<T, Error>
Wait for the given predicate to be fulfilled.
fn wait_for_peers(&self, count: usize) -> Result<(), Error>
Wait for a given number of peers to be connected.
fn wait_for_ready(&self) -> Result<(), Error>
Wait for the node to be ready and in sync with the blockchain.
fn wait_for_height(&self, h: Height) -> Result<BlockHash, Error>
Wait for the node's active chain to reach a certain height. The hash at that height is returned.
fn shutdown(self) -> Result<(), Error>
Shutdown the node process.
Implementors
impl Handle for NodeHandle[src]
type Message = NetworkMessage
type Event = Event<NetworkMessage>
fn get_tip(&self) -> Result<BlockHeader, Error>[src]
fn get_block(&self, hash: &BlockHash) -> Result<Block, Error>[src]
fn connect(&self, addr: SocketAddr) -> Result<Link, Error>[src]
fn import_headers(
&self,
headers: Vec<BlockHeader>
) -> Result<Result<ImportResult, Error>, Error>[src]
&self,
headers: Vec<BlockHeader>
) -> Result<Result<ImportResult, Error>, Error>
fn receive(&self, from: SocketAddr, msg: NetworkMessage) -> Result<(), Error>[src]
fn submit_transaction(&self, _tx: Transaction) -> Result<(), Error>[src]
fn wait<F, T>(&self, f: F) -> Result<T, Error> where
F: Fn(Event<NetworkMessage>) -> Option<T>, [src]
F: Fn(Event<NetworkMessage>) -> Option<T>,
Subscribe to the event feed, and wait for the given function to return something, or timeout if the specified amount of time has elapsed.