pub trait NodeHooks {
    // Required methods
    fn on_block_received(&mut self, block: &Block);
    fn on_transaction_received(&mut self, transaction: &Transaction);
    fn on_peer_connected(&mut self, peer: &u32);
    fn on_peer_disconnected(&mut self, peer: &u32);
    fn on_header_received(&mut self, header: &BlockHeader);
}
Expand description

NodeHooks is a trait that defines the hooks that a node can use to interact with the network and the blockchain. Every time an event happens, the node will call the corresponding hook.

Required Methods§

source

fn on_block_received(&mut self, block: &Block)

We’ve received a new block

source

fn on_transaction_received(&mut self, transaction: &Transaction)

We’ve received a new transaction

source

fn on_peer_connected(&mut self, peer: &u32)

We’ve received a new peer

source

fn on_peer_disconnected(&mut self, peer: &u32)

We’ve lost a peer

source

fn on_header_received(&mut self, header: &BlockHeader)

We’ve received a new header

Implementors§