pub struct BlockLocators<N: Network> {
pub recents: IndexMap<u32, N::BlockHash>,
pub checkpoints: IndexMap<u32, N::BlockHash>,
}Fields§
§recents: IndexMap<u32, N::BlockHash>The map of recent blocks.
checkpoints: IndexMap<u32, N::BlockHash>The map of block checkpoints.
Implementations§
source§impl<N: Network> BlockLocators<N>
impl<N: Network> BlockLocators<N>
sourcepub fn new(
recents: IndexMap<u32, N::BlockHash>,
checkpoints: IndexMap<u32, N::BlockHash>
) -> Self
pub fn new( recents: IndexMap<u32, N::BlockHash>, checkpoints: IndexMap<u32, N::BlockHash> ) -> Self
Initializes a new instance of the block locators.
sourcepub fn new_genesis(genesis_hash: N::BlockHash) -> Self
pub fn new_genesis(genesis_hash: N::BlockHash) -> Self
Initializes a new genesis instance of the block locators.
sourcepub fn latest_locator_height(&self) -> u32
pub fn latest_locator_height(&self) -> u32
Returns the latest locator height.
sourcepub fn get_hash(&self, height: u32) -> Option<N::BlockHash>
pub fn get_hash(&self, height: u32) -> Option<N::BlockHash>
Returns the block hash for the given block height, if it exists.
sourcepub fn is_consistent_with(&self, other: &Self) -> bool
pub fn is_consistent_with(&self, other: &Self) -> bool
Returns true if the given block locators are consistent with this one.
This function assumes the given block locators are well-formed.
sourcepub fn ensure_is_valid(&self) -> Result<()>
pub fn ensure_is_valid(&self) -> Result<()>
Checks that this block locators are well-formed.
sourcepub fn ensure_is_consistent_with(&self, other: &Self) -> Result<()>
pub fn ensure_is_consistent_with(&self, other: &Self) -> Result<()>
Returns true if the given block locators are consistent with this one.
This function assumes the given block locators are well-formed.
source§impl<N: Network> BlockLocators<N>
impl<N: Network> BlockLocators<N>
sourcepub fn check_consistent_block_locators(
old_locators: &BlockLocators<N>,
new_locators: &BlockLocators<N>
) -> Result<()>
pub fn check_consistent_block_locators( old_locators: &BlockLocators<N>, new_locators: &BlockLocators<N> ) -> Result<()>
Checks the old and new block locators share a consistent view of block history. This function assumes the given block locators are well-formed.
Trait Implementations§
source§impl<N: Clone + Network> Clone for BlockLocators<N>where
N::BlockHash: Clone,
impl<N: Clone + Network> Clone for BlockLocators<N>where N::BlockHash: Clone,
source§fn clone(&self) -> BlockLocators<N>
fn clone(&self) -> BlockLocators<N>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<'de, N: Network> Deserialize<'de> for BlockLocators<N>
impl<'de, N: Network> Deserialize<'de> for BlockLocators<N>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<N: Network> IntoIterator for BlockLocators<N>
impl<N: Network> IntoIterator for BlockLocators<N>
source§impl<N: PartialEq + Network> PartialEq<BlockLocators<N>> for BlockLocators<N>where
N::BlockHash: PartialEq,
impl<N: PartialEq + Network> PartialEq<BlockLocators<N>> for BlockLocators<N>where N::BlockHash: PartialEq,
source§fn eq(&self, other: &BlockLocators<N>) -> bool
fn eq(&self, other: &BlockLocators<N>) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl<N: Network> Serialize for BlockLocators<N>
impl<N: Network> Serialize for BlockLocators<N>
impl<N: Eq + Network> Eq for BlockLocators<N>where N::BlockHash: Eq,
impl<N: Network> StructuralEq for BlockLocators<N>
impl<N: Network> StructuralPartialEq for BlockLocators<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for BlockLocators<N>where <N as Network>::BlockHash: RefUnwindSafe,
impl<N> Send for BlockLocators<N>
impl<N> Sync for BlockLocators<N>
impl<N> Unpin for BlockLocators<N>where <N as Network>::BlockHash: Unpin,
impl<N> UnwindSafe for BlockLocators<N>where <N as Network>::BlockHash: UnwindSafe,
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
§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,
fn take_from_value<D>( value: &mut Value, field: &str ) -> Result<T, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more