[][src]Trait grin_p2p::types::ChainAdapter

pub trait ChainAdapter: Sync + Send {
    fn total_difficulty(&self) -> Difficulty;
fn total_height(&self) -> u64;
fn transaction_received(&self, tx: Transaction, stem: bool);
fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>;
fn tx_kernel_received(&self, kernel_hash: Hash, addr: SocketAddr);
fn block_received(&self, b: Block, addr: SocketAddr) -> bool;
fn compact_block_received(&self, cb: CompactBlock, addr: SocketAddr) -> bool;
fn header_received(&self, bh: BlockHeader, addr: SocketAddr) -> bool;
fn headers_received(&self, bh: &[BlockHeader], addr: SocketAddr) -> bool;
fn locate_headers(&self, locator: &[Hash]) -> Vec<BlockHeader>;
fn get_block(&self, h: Hash) -> Option<Block>;
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>;
fn txhashset_receive_ready(&self) -> bool;
fn txhashset_download_update(
        &self,
        start_time: DateTime<Utc>,
        downloaded_size: u64,
        total_size: u64
    ) -> bool;
fn txhashset_write(
        &self,
        h: Hash,
        txhashset_data: File,
        peer_addr: SocketAddr
    ) -> bool; }

Bridge between the networking layer and the rest of the system. Handles the forwarding or querying of blocks and transactions from the network among other things.

Required methods

Current total difficulty on our chain

Current total height

A valid transaction has been received from one of our peers

A block has been received from one of our peers. Returns true if the block could be handled properly and is not deemed defective by the chain. Returning false means the block will never be valid and may result in the peer being banned.

A set of block header has been received, typically in response to a block header request.

Finds a list of block headers based on the provided locator. Tries to identify the common chain and gets the headers that follow it immediately.

Gets a full block by its hash.

Provides a reading view into the current txhashset state as well as the required indexes for a consumer to rewind to a consistant state at the provided block hash.

Whether the node is ready to accept a new txhashset. If this isn't the case, the archive is provided without being requested and likely an attack attempt. This should be checked before downloading the whole state data.

Update txhashset downloading progress

Writes a reading view on a txhashset state that's been provided to us. If we're willing to accept that new state, the data stream will be read as a zip file, unzipped and the resulting state files should be rewound to the provided indexes.

Loading content...

Implementors

impl ChainAdapter for DummyAdapter
[src]

impl ChainAdapter for Peers
[src]

Loading content...