Trait McHashDataSource

Source
pub trait McHashDataSource {
    // Required methods
    fn get_latest_stable_block_for<'life0, 'async_trait>(
        &'life0 self,
        reference_timestamp: Timestamp,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_stable_block_for<'life0, 'async_trait>(
        &'life0 self,
        hash: McBlockHash,
        reference_timestamp: Timestamp,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_block_by_hash<'life0, 'async_trait>(
        &'life0 self,
        hash: McBlockHash,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Data source API used by McHashInherentDataProvider

Required Methods§

Source

fn get_latest_stable_block_for<'life0, 'async_trait>( &'life0 self, reference_timestamp: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query for the currently latest stable block with timestamp within the allowable_range(reference_timestamp) = [reference_timestamp - seconds(max_slot_boundary), reference_timestamp - seconds(slot_boundary)] where max_slot_boundary is 3 * security_parameter/active_slot_coeff (3k/f) and min_slot_boundary is security_parameter/active_slot_coeff (k/f).

§Arguments
  • reference_timestamp - restricts the timestamps of MC blocks
§Returns
  • Some(block) - the latest stable block, with timestamp in the allowable range
  • None - none of the blocks is stable, and with timestamp valid in according to reference_timestamp
Source

fn get_stable_block_for<'life0, 'async_trait>( &'life0 self, hash: McBlockHash, reference_timestamp: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find block by hash, filtered by block timestamp being in allowable_range(reference_timestamp)

§Arguments
  • hash - the hash of the block
  • reference_timestamp - restricts the timestamp of the MC block
§Returns
  • Some(block) - the block with given hash, with timestamp in the allowable range
  • None - no stable block with given hash and timestamp in the allowable range exists
Source

fn get_block_by_hash<'life0, 'async_trait>( &'life0 self, hash: McBlockHash, ) -> Pin<Box<dyn Future<Output = Result<Option<MainchainBlock>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find block by hash.

§Arguments
  • hash - the hash of the block
§Returns
  • Some(block) - the block with given hash
  • None - no block with the given hash was found

Implementors§