hotstuff_rs::block_sync::client

Struct BlockSyncClient

source
pub(crate) struct BlockSyncClient<N: Network> {
    config: BlockSyncClientConfiguration,
    receiver: BlockSyncClientStub,
    sender: SenderHandle<N>,
    validator_set_update_handle: ValidatorSetUpdateHandle<N>,
    block_sync_client_state: BlockSyncClientState,
    event_publisher: Option<Sender<Event>>,
}

Fields§

§config: BlockSyncClientConfiguration§receiver: BlockSyncClientStub§sender: SenderHandle<N>§validator_set_update_handle: ValidatorSetUpdateHandle<N>§block_sync_client_state: BlockSyncClientState§event_publisher: Option<Sender<Event>>

Implementations§

source§

impl<N: Network> BlockSyncClient<N>

source

pub(crate) fn new( config: BlockSyncClientConfiguration, receiver: BlockSyncClientStub, sender: SenderHandle<N>, validator_set_update_handle: ValidatorSetUpdateHandle<N>, event_publisher: Option<Sender<Event>>, ) -> Self

Create a new instance of the BlockSyncClient.

source

pub(crate) fn on_receive_msg<K: KVStore>( &mut self, msg: BlockSyncAdvertiseMessage, origin: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, app: &mut impl App<K>, ) -> Result<(), BlockSyncClientError>

Process a received BlockSyncAdvertiseMessage.

source

pub(crate) fn tick<K: KVStore>( &mut self, block_tree: &mut BlockTreeSingleton<K>, app: &mut impl App<K>, ) -> Result<(), BlockSyncClientError>

Update the BlockSyncClient’s internal state, and possibly trigger sync on reaching sync trigger timeout.

source

fn on_receive_advertise_block<K: KVStore>( &mut self, advertise_block: AdvertiseBlock, origin: &VerifyingKey, block_tree: &BlockTreeSingleton<K>, ) -> Result<(), BlockSyncClientError>

Process an AdvertiseBlock message. This can lead to registering the sender as an available sync server and storing information on the server’s claimed highest committed block height.

source

fn on_receive_advertise_pc<K: KVStore>( &mut self, advertise_pc: AdvertisePC, origin: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, app: &mut impl App<K>, ) -> Result<(), BlockSyncClientError>

Process an AdvertisePC message. This can lead to triggering sync if the criteria for event-based sync trigger are met.

source

fn sync<K: KVStore>( &mut self, block_tree: &mut BlockTreeSingleton<K>, app: &mut impl App<K>, ) -> Result<(), BlockSyncClientError>

Sync with a randomly selected peer.

source

fn sync_with<K: KVStore>( &mut self, peer: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, app: &mut impl App<K>, ) -> Result<(), BlockSyncClientError>

Sync with a given peer. This involves possibly multiple iterations of:

  1. Sending a sync request to the peer for a given number of blocks,
  2. Waiting for a response from the peer,
  3. Processing the response: validating blocks, inserting into the block tree, performing related block tree and app state updates.

As part of this process, a sync peer can be blacklisted if:

  1. It sends an incorrect or unsafe block,
  2. It sends a block that is not validated by the App,
  3. It fails to provide the minimum number of blocks it committed to providing through AdvertiseBlock.

Auto Trait Implementations§

§

impl<N> Freeze for BlockSyncClient<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for BlockSyncClient<N>
where N: RefUnwindSafe,

§

impl<N> Send for BlockSyncClient<N>

§

impl<N> !Sync for BlockSyncClient<N>

§

impl<N> Unpin for BlockSyncClient<N>
where N: Unpin,

§

impl<N> UnwindSafe for BlockSyncClient<N>
where N: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V