logo
pub struct ChainSync<ZN, ZS, ZV, ZSTip> where
    ZN: Service<Request, Response = Response, Error = BoxError> + Send + Sync + Clone + 'static,
    ZN::Future: Send,
    ZS: Service<Request, Response = Response, Error = BoxError> + Send + Sync + Clone + 'static,
    ZS::Future: Send,
    ZV: Service<Arc<Block>, Response = Hash, Error = BoxError> + Send + Sync + Clone + 'static,
    ZV::Future: Send,
    ZSTip: ChainTip + Clone + Send + 'static, 
{ genesis_hash: Hash, lookahead_limit: usize, tip_network: Timeout<ZN>, downloads: Pin<Box<Downloads<Hedge<ConcurrencyLimit<Retry<RetryLimit, Timeout<ZN>>>, AlwaysHedge>, Timeout<ZV>, ZSTip>>>, state: ZS, latest_chain_tip: ZSTip, prospective_tips: HashSet<CheckedTip>, recent_syncs: RecentSyncLengths, }

Fields

genesis_hash: Hash

The genesis hash for the configured network

lookahead_limit: usize

The configured lookahead limit, after applying the minimum limit.

tip_network: Timeout<ZN>

A network service which is used to perform ObtainTips and ExtendTips requests.

Has no retry logic, because failover is handled using fanout.

downloads: Pin<Box<Downloads<Hedge<ConcurrencyLimit<Retry<RetryLimit, Timeout<ZN>>>, AlwaysHedge>, Timeout<ZV>, ZSTip>>>

A service which downloads and verifies blocks, using the provided network and verifier services.

state: ZS

The cached block chain state.

latest_chain_tip: ZSTip

Allows efficient access to the best tip of the blockchain.

prospective_tips: HashSet<CheckedTip>

The tips that the syncer is currently following.

recent_syncs: RecentSyncLengths

The lengths of recent sync responses.

Implementations

Polls the network to determine whether further blocks are available and downloads them.

This component is used for initial block sync, but the Inbound service is responsible for participating in the gossip protocols used for block diffusion.

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
  • verifier: the zebra-consensus verifier that checks the chain
  • state: the zebra-state that stores the chain
  • latest_chain_tip: the latest chain tip from state

Also returns a SyncStatus to check if the syncer has likely reached the chain tip.

Runs the syncer to synchronize the chain and keep it synchronized.

Tries to synchronize the chain as far as it can.

Obtains some prospective tips and iteratively tries to extend them and download the missing blocks.

Returns Ok if it was able to synchronize as much of the chain as it could, and then ran out of prospective tips. This happens when synchronization finishes or if Zebra ended up following a fork. Either way, Zebra should attempt to obtain some more tips.

Returns Err if there was an unrecoverable error and restarting the synchronization is necessary.

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

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

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

Handles a response for a requested block.

Returns Ok if the block was successfully verified and committed to the state, or if an expected error occurred, so that the synchronization can continue normally.

Returns Err if an unexpected error occurred, to force the synchronizer to restart.

Handles a response to a syncer request.

Returns Ok if the request was successful, or if an expected error occurred, so that the synchronization can continue normally.

Returns Err if an unexpected error occurred, to force the synchronizer to restart.

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

BUG: check if the hash is in any chain (#862) Depth only checks the main chain.

Return if the sync should be restarted based on the given error from the block downloader and verifier stream.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Borrow this concrete type as a &dyn Any

Borrow this concrete type as a &mut dyn Any

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted. Read more

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted. Read more

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Formats each item in a sequence. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Set the foreground color generically Read more

Set the background color generically. Read more

Change the foreground color to black

Change the foreground color to black

Change the foreground color to red

Change the foreground color to red

Change the foreground color to green

Change the foreground color to green

Change the foreground color to yellow

Change the foreground color to yellow

Change the foreground color to blue

Change the foreground color to blue

Change the foreground color to magenta

Change the foreground color to magenta

Change the foreground color to purple

Change the foreground color to purple

Change the foreground color to cyan

Change the foreground color to cyan

Change the foreground color to white

Change the foreground color to white

Change the foreground color to bright black

Change the foreground color to bright black

Change the foreground color to bright red

Change the foreground color to bright red

Change the foreground color to bright green

Change the foreground color to bright green

Change the foreground color to bright yellow

Change the foreground color to bright yellow

Change the foreground color to bright blue

Change the foreground color to bright blue

Change the foreground color to bright magenta

Change the foreground color to bright magenta

Change the foreground color to bright purple

Change the foreground color to bright purple

Change the foreground color to bright cyan

Change the foreground color to bright cyan

Change the foreground color to bright white

Change the foreground color to bright white

Make the text bold

Make the text dim

Make the text italicized

Make the text italicized

Make the text blink

Make the text blink (but fast!)

Swap the foreground and background colors

Hide the text

Cross out the text

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more

Sets the foreground color to an RGB value.

Sets the background color to an RGB value.

Apply a runtime-determined style

Set the foreground color generically Read more

Set the background color generically. Read more

Change the foreground color to black

Change the background color to black

Change the foreground color to red

Change the background color to red

Change the foreground color to green

Change the background color to green

Change the foreground color to yellow

Change the background color to yellow

Change the foreground color to blue

Change the background color to blue

Change the foreground color to magenta

Change the background color to magenta

Change the foreground color to purple

Change the background color to purple

Change the foreground color to cyan

Change the background color to cyan

Change the foreground color to white

Change the background color to white

Change the foreground color to the terminal default

Change the background color to the terminal default

Change the foreground color to bright black

Change the background color to bright black

Change the foreground color to bright red

Change the background color to bright red

Change the foreground color to bright green

Change the background color to bright green

Change the foreground color to bright yellow

Change the background color to bright yellow

Change the foreground color to bright blue

Change the background color to bright blue

Change the foreground color to bright magenta

Change the background color to bright magenta

Change the foreground color to bright purple

Change the background color to bright purple

Change the foreground color to bright cyan

Change the background color to bright cyan

Change the foreground color to bright white

Change the background color to bright white

Make the text bold

Make the text dim

Make the text italicized

Make the text italicized

Make the text blink

Make the text blink (but fast!)

Swap the foreground and background colors

Hide the text

Cross out the text

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more

Set the foreground color to a specific RGB value.

Set the background color to a specific RGB value.

Sets the foreground color to an RGB value.

Sets the background color to an RGB value.

Apply a runtime-determined style

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Converts the type into a Result that can be sent as a response.

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more