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, checking the validity 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, without checking the validity 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>
impl<N: Clone + Network> Clone for BlockLocators<N>
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: 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>
impl<N: Network> StructuralPartialEq for BlockLocators<N>
Auto Trait Implementations§
impl<N> Freeze for BlockLocators<N>
impl<N> RefUnwindSafe for BlockLocators<N>
impl<N> Send for BlockLocators<N>
impl<N> Sync for BlockLocators<N>
impl<N> Unpin for BlockLocators<N>
impl<N> UnwindSafe for BlockLocators<N>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§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 Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more