Skip to main content

ChainSource

Trait ChainSource 

Source
pub trait ChainSource: Send + Sync {
    // Required methods
    fn genesis(&self) -> Result<BlockHash, Error>;
    fn tip(&self) -> Result<ChainPoint, Error>;
    fn header(&self, height: u64) -> Result<Header, Error>;
    fn block(&self, height: u64) -> Result<Vec<u8>, Error>;

    // Provided method
    fn chain_peers(&self) -> Result<u64, Error> { ... }
}
Expand description

Port implemented by a chain verifier, not by an untrusted remote JSON API. The implementation owns header difficulty, PoW and branch selection. Bodies remain untrusted bytes and are checked again against the selected header. Provider-claimed observations used by autonomous clients are a different contract and do not enter this port by relabelling them as verified.

Required Methods§

Source

fn genesis(&self) -> Result<BlockHash, Error>

Source

fn tip(&self) -> Result<ChainPoint, Error>

Source

fn header(&self, height: u64) -> Result<Header, Error>

Source

fn block(&self, height: u64) -> Result<Vec<u8>, Error>

Provided Methods§

Source

fn chain_peers(&self) -> Result<u64, Error>

Connected chain peers now; 0 for sources without a peer network.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§