Trait narwhal_primary::block_synchronizer::handler::Handler
source · [−]pub trait Handler {
fn get_and_synchronize_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<BlockSynchronizeResult<BlockHeader>>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn synchronize_block_payloads<'life0, 'async_trait>(
&'life0 self,
certificates: Vec<Certificate>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Handler defines an interface to allow us access the BlockSycnhronizer’s functionality in a synchronous way without having to deal with message emission. The BlockSynchronizer on its own for the certificates that fetches on the fly from peers doesn’t care/deal about any other validation checks than the basic verification offered via the certificate entity it self. For that reason the Handler offers methods to submit the fetched from peers certificates for further validation & processing (e.x ensure parents history is causally complete) to the core and wait until the certificate has been processed, before it returns it back as result.
Required Methods
sourcefn get_and_synchronize_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_and_synchronize_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
It retrieves the requested blocks via the block_synchronizer making sure though that they are fully validated. The certificates will only be returned when they have properly processed via the core module and made sure all the requirements have been fulfilled.
sourcefn get_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<BlockSynchronizeResult<BlockHeader>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_block_headers<'life0, 'async_trait>(
&'life0 self,
block_ids: Vec<CertificateDigest>
) -> Pin<Box<dyn Future<Output = Vec<BlockSynchronizeResult<BlockHeader>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
It retrieves the requested blocks via the block_synchronizer, but it doesn’t synchronize the fetched headers, meaning that no processing will take place (causal completion etc).
sourcefn synchronize_block_payloads<'life0, 'async_trait>(
&'life0 self,
certificates: Vec<Certificate>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn synchronize_block_payloads<'life0, 'async_trait>(
&'life0 self,
certificates: Vec<Certificate>
) -> Pin<Box<dyn Future<Output = Vec<Result<Certificate, Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Synchronizes the block payload for the provided certificates via the block synchronizer and returns the result back.