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>
) -> Result<Self>
pub fn new( recents: IndexMap<u32, N::BlockHash>, checkpoints: IndexMap<u32, N::BlockHash> ) -> Result<Self>
Initializes a new instance of the block locators.
sourcepub fn new_unchecked(
recents: IndexMap<u32, N::BlockHash>,
checkpoints: IndexMap<u32, N::BlockHash>
) -> Self
pub fn new_unchecked( 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.
source§impl<N: Network> BlockLocators<N>
impl<N: Network> BlockLocators<N>
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>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
source§impl<N: Network> FromBytes for BlockLocators<N>
impl<N: Network> FromBytes for BlockLocators<N>
source§impl<N: Network> IntoIterator for BlockLocators<N>
impl<N: Network> IntoIterator for BlockLocators<N>
source§impl<N: PartialEq + Network> PartialEq for BlockLocators<N>where
N::BlockHash: PartialEq,
impl<N: PartialEq + Network> PartialEq for BlockLocators<N>where
N::BlockHash: PartialEq,
source§fn eq(&self, other: &BlockLocators<N>) -> bool
fn eq(&self, other: &BlockLocators<N>) -> bool
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>
source§impl<N: Network> ToBytes for BlockLocators<N>
impl<N: Network> ToBytes 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
§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>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.