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>

source

pub fn new( recents: IndexMap<u32, N::BlockHash>, checkpoints: IndexMap<u32, N::BlockHash> ) -> Result<Self>

Initializes a new instance of the block locators.

source

pub fn new_unchecked( recents: IndexMap<u32, N::BlockHash>, checkpoints: IndexMap<u32, N::BlockHash> ) -> Self

Initializes a new instance of the block locators.

source

pub fn new_genesis(genesis_hash: N::BlockHash) -> Self

Initializes a new genesis instance of the block locators.

source§

impl<N: Network> BlockLocators<N>

source

pub fn latest_locator_height(&self) -> u32

Returns the latest locator height.

source

pub fn get_hash(&self, height: u32) -> Option<N::BlockHash>

Returns the block hash for the given block height, if it exists.

source

pub fn is_valid(&self) -> bool

Returns true if the block locators are well-formed.

source

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.

source

pub fn ensure_is_valid(&self) -> Result<()>

Checks that this block locators are well-formed.

source

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>

source

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.

source

pub fn check_block_locators( recents: &IndexMap<u32, N::BlockHash>, checkpoints: &IndexMap<u32, N::BlockHash> ) -> Result<()>

Checks that the block locators are well-formed.

Trait Implementations§

source§

impl<N: Clone + Network> Clone for BlockLocators<N>
where N::BlockHash: Clone,

source§

fn clone(&self) -> BlockLocators<N>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<N: Debug + Network> Debug for BlockLocators<N>
where N::BlockHash: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, N: Network> Deserialize<'de> for BlockLocators<N>

source§

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> FromBytes for BlockLocators<N>

source§

fn read_le<R: Read>(reader: R) -> IoResult<Self>

Reads Self from reader as little-endian bytes.
§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

Returns Self from a byte array in little-endian order.
source§

impl<N: Network> IntoIterator for BlockLocators<N>

§

type IntoIter = IntoIter<u32, <N as Network>::BlockHash>

Which kind of iterator are we turning this into?
§

type Item = (u32, <N as Network>::BlockHash)

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<N: PartialEq + Network> PartialEq for BlockLocators<N>
where N::BlockHash: PartialEq,

source§

fn eq(&self, other: &BlockLocators<N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N: Network> Serialize for BlockLocators<N>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<N: Network> ToBytes for BlockLocators<N>

source§

fn write_le<W: Write>(&self, writer: W) -> IoResult<()>

Writes self into writer as little-endian bytes.
§

fn to_bytes_le(&self) -> Result<Vec<u8>, Error>
where Self: Sized,

Returns self as a byte array in little-endian order.
source§

impl<N: Eq + Network> Eq for BlockLocators<N>
where N::BlockHash: Eq,

source§

impl<N: Network> StructuralEq for BlockLocators<N>

source§

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> 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
§

impl<'de, T> DeserializeExt<'de> for T

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,