pub struct BlockIdentifier {
pub chain_id: u32,
pub number: u64,
pub hash: Hash256,
}
Expand description
Type used to identify blocks.
In principle a block is uniquely defined by its hash, however it may be useful to know where to find the block.
A BlockIdentifier
adds the chain-id and block-number to the hash, so we can easily lookup a block based on its identifier.
Fields§
§chain_id: u32
Chain-ID of the block.
number: u64
Number of the block.
hash: Hash256
Hash of the block.
Note: The hash of a block is not the hash over the serialized data.
It is the sum of three hashes: Hash(Header) + MerkleRoot(Txs) + MerkleRoot(SignatureWithKeys)
Implementations§
Source§impl BlockIdentifier
impl BlockIdentifier
Sourcepub fn new(chain_id: u32, number: u64, hash: Hash256) -> BlockIdentifier
pub fn new(chain_id: u32, number: u64, hash: Hash256) -> BlockIdentifier
Constructs a new BlockIdentifier
from its raw parts
pub fn genesis(chain_id: u32) -> BlockIdentifier
Sourcepub fn from_bytes(
bytes: Vec<u8>,
) -> Result<BlockIdentifier, InvalidBlockIdentifier>
pub fn from_bytes( bytes: Vec<u8>, ) -> Result<BlockIdentifier, InvalidBlockIdentifier>
Decodes a BlockIdentifier
from bytes
Trait Implementations§
Source§impl Clone for BlockIdentifier
impl Clone for BlockIdentifier
Source§fn clone(&self) -> BlockIdentifier
fn clone(&self) -> BlockIdentifier
Returns a duplicate 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 Debug for BlockIdentifier
impl Debug for BlockIdentifier
Source§impl<'de> Deserialize<'de> for BlockIdentifier
impl<'de> Deserialize<'de> for BlockIdentifier
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockIdentifier, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockIdentifier, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for BlockIdentifier
impl Display for BlockIdentifier
Source§impl Hash for BlockIdentifier
impl Hash for BlockIdentifier
Source§impl Ord for BlockIdentifier
impl Ord for BlockIdentifier
Source§fn cmp(&self, other: &BlockIdentifier) -> Ordering
fn cmp(&self, other: &BlockIdentifier) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for BlockIdentifier
impl PartialEq for BlockIdentifier
Source§impl PartialOrd for BlockIdentifier
impl PartialOrd for BlockIdentifier
Source§impl Serialize for BlockIdentifier
impl Serialize for BlockIdentifier
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for BlockIdentifier
impl StructuralPartialEq for BlockIdentifier
Auto Trait Implementations§
impl Freeze for BlockIdentifier
impl RefUnwindSafe for BlockIdentifier
impl Send for BlockIdentifier
impl Sync for BlockIdentifier
impl Unpin for BlockIdentifier
impl UnwindSafe for BlockIdentifier
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