[][src]Struct zebrad::components::sync::ChainSync

pub struct ChainSync<ZN, ZS, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZN::Future: Send,
    ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZS::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
{ tip_network: Timeout<ZN>, block_network: Retry<RetryLimit, Timeout<ZN>>, state: ZS, verifier: Timeout<ZV>, prospective_tips: HashSet<CheckedTip>, pending_blocks: Pin<Box<FuturesUnordered<JoinHandle<Result<Hash, (Report, Hash)>>>>>, genesis_hash: Hash, }

Fields

tip_network: Timeout<ZN>

Used to perform ObtainTips and ExtendTips requests, with no retry logic (failover is handled using fanout).

block_network: Retry<RetryLimit, Timeout<ZN>>

Used to download blocks, with retry logic.

state: ZSverifier: Timeout<ZV>prospective_tips: HashSet<CheckedTip>pending_blocks: Pin<Box<FuturesUnordered<JoinHandle<Result<Hash, (Report, Hash)>>>>>genesis_hash: Hash

Implementations

impl<ZN, ZS, ZV> ChainSync<ZN, ZS, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZN::Future: Send,
    ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZS::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

pub fn new(chain: Network, peers: ZN, state: ZS, verifier: ZV) -> Self[src]

Returns a new syncer instance, using:

  • chain: the zebra-chain Network to download (Mainnet or Testnet)
  • peers: the zebra-network peers to contact for downloads
  • state: the zebra-state that stores the chain
  • verifier: the zebra-consensus verifier that checks the chain

pub async fn sync<'_>(&'_ mut self) -> Result<(), Report>[src]

async fn obtain_tips<'_>(&'_ mut self) -> Result<(), Report>[src]

Given a block_locator list fan out request for subsequent hashes to multiple peers

async fn extend_tips<'_>(&'_ mut self) -> Result<(), Report>[src]

async fn request_genesis<'_>(&'_ mut self) -> Result<(), Report>[src]

Download and verify the genesis block, if it isn't currently known to our node.

async fn request_blocks<'_>(
    &'_ mut self,
    hashes: Vec<Hash>
) -> Result<(), Report>
[src]

Queue download and verify tasks for each block that isn't currently known to our node

async fn state_contains<'_>(&'_ mut self, hash: Hash) -> Result<bool, Report>[src]

Returns true if the hash is present in the state, and false if the hash is not present in the state.

TODO: handle multiple tips in the state.

fn update_metrics(&self)[src]

Trait Implementations

impl<ZN: Debug, ZS: Debug, ZV: Debug> Debug for ChainSync<ZN, ZS, ZV> where
    ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZN::Future: Send,
    ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZS::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static,
    ZV::Future: Send
[src]

Auto Trait Implementations

impl<ZN, ZS, ZV> !RefUnwindSafe for ChainSync<ZN, ZS, ZV>

impl<ZN, ZS, ZV> Send for ChainSync<ZN, ZS, ZV>

impl<ZN, ZS, ZV> Sync for ChainSync<ZN, ZS, ZV> where
    ZN: Sync,
    ZS: Sync,
    ZV: Sync

impl<ZN, ZS, ZV> Unpin for ChainSync<ZN, ZS, ZV> where
    ZN: Unpin,
    ZS: Unpin,
    ZV: Unpin

impl<ZN, ZS, ZV> !UnwindSafe for ChainSync<ZN, ZS, ZV>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsAny for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Erased for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<D> OwoColorize for D

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]