pub struct BlockchainSyncState { /* private fields */ }
Expand description
Maintains the state for fetching blocks from other peers into this peer. Tries to fetch the blocks in the most resource efficient way possible.
Implementations§
Source§impl BlockchainSyncState
impl BlockchainSyncState
pub fn new(batch_size: usize) -> BlockchainSyncState
pub fn get_fetching_block_count(&self) -> BlockId
Sourcepub fn get_blocks_to_fetch_per_peer(
&mut self,
) -> HashMap<PeerIndex, Vec<(SaitoHash, BlockId)>>
pub fn get_blocks_to_fetch_per_peer( &mut self, ) -> HashMap<PeerIndex, Vec<(SaitoHash, BlockId)>>
Generates the list of blocks which needs to be fetched next. A list is generated per each peer since we can fetch from multiple peers concurrently.
Sourcepub fn mark_as_fetched(&mut self, hash: SaitoHash)
pub fn mark_as_fetched(&mut self, hash: SaitoHash)
Sourcepub async fn add_entry(
&mut self,
block_hash: SaitoHash,
block_id: BlockId,
peer_index: PeerIndex,
peer_lock: Arc<RwLock<PeerCollection>>,
)
pub async fn add_entry( &mut self, block_hash: SaitoHash, block_id: BlockId, peer_index: PeerIndex, peer_lock: Arc<RwLock<PeerCollection>>, )
Sourcepub fn remove_entry(&mut self, block_hash: SaitoHash)
pub fn remove_entry(&mut self, block_hash: SaitoHash)
pub fn get_stats(&self) -> Vec<String>
Auto Trait Implementations§
impl Freeze for BlockchainSyncState
impl RefUnwindSafe for BlockchainSyncState
impl Send for BlockchainSyncState
impl Sync for BlockchainSyncState
impl Unpin for BlockchainSyncState
impl UnwindSafe for BlockchainSyncState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more