pub struct BlockReader<'r>(/* private fields */);
Implementations§
Source§impl<'r> BlockReader<'r>
impl<'r> BlockReader<'r>
Sourcepub fn calc_header_hash(&self) -> Byte32
pub fn calc_header_hash(&self) -> Byte32
Calls HeaderReader.calc_header_hash()
for self.header()
.
Sourcepub fn calc_proposals_hash(&self) -> Byte32
pub fn calc_proposals_hash(&self) -> Byte32
Sourcepub fn calc_uncles_hash(&self) -> Byte32
pub fn calc_uncles_hash(&self) -> Byte32
Sourcepub fn calc_extension_hash(&self) -> Option<Byte32>
pub fn calc_extension_hash(&self) -> Option<Byte32>
Calculates the hash for the extension.
If there is an extension (unknown for now), calculate the hash of its data.
Sourcepub fn calc_tx_hashes(&self) -> Vec<Byte32>
pub fn calc_tx_hashes(&self) -> Vec<Byte32>
Calculates transaction hashes for all transactions in the block.
Sourcepub fn calc_tx_witness_hashes(&self) -> Vec<Byte32>
pub fn calc_tx_witness_hashes(&self) -> Vec<Byte32>
Calculates transaction witness hashes for all transactions in the block.
Source§impl<'r> BlockReader<'r>
impl<'r> BlockReader<'r>
Sourcepub fn extra_field(&self, index: usize) -> Option<&[u8]>
pub fn extra_field(&self, index: usize) -> Option<&[u8]>
Gets the i-th extra field if it exists; i started from 0.
Sourcepub fn extension(&self) -> Option<BytesReader<'_>>
pub fn extension(&self) -> Option<BytesReader<'_>>
Gets the extension field if it existed.
§Panics
Panics if the first extra field exists but not a valid BytesReader
.
Source§impl<'r> BlockReader<'r>
impl<'r> BlockReader<'r>
Sourcepub fn serialized_size_without_uncle_proposals(&self) -> usize
pub fn serialized_size_without_uncle_proposals(&self) -> usize
Calculates the serialized size of Block
without uncle proposals.
§Computational Steps
- Calculates the total serialized size of
Block
, marks it asB
. - Calculates the serialized size
ProposalShortIdVec
for each uncle block, marks them asP0, P1, ..., Pn
. - Even an uncle has no proposals, the
ProposalShortIdVec
still has a header contains its total size, the size ismolecule::NUMBER_SIZE
, marks it ash
. - So the serialized size of
Block
without uncle proposals is:B - sum(P0 - h, P1 - h, ..., Pn - h)
Source§impl<'r> BlockReader<'r>
impl<'r> BlockReader<'r>
pub const FIELD_COUNT: usize = 4usize
pub fn total_size(&self) -> usize
pub fn field_count(&self) -> usize
pub fn count_extra_fields(&self) -> usize
pub fn has_extra_fields(&self) -> bool
pub fn header(&self) -> HeaderReader<'r>
pub fn uncles(&self) -> UncleBlockVecReader<'r>
pub fn transactions(&self) -> TransactionVecReader<'r>
pub fn proposals(&self) -> ProposalShortIdVecReader<'r>
Trait Implementations§
Source§impl<'r> CalcExtraHash for BlockReader<'r>
impl<'r> CalcExtraHash for BlockReader<'r>
Source§fn calc_extra_hash(&self) -> ExtraHashView
fn calc_extra_hash(&self) -> ExtraHashView
Calculates the extra hash, which is a combination of the uncles hash and the extension hash.
- If there is no extension, extra hash is the same as the uncles hash.
- If there is a extension, then extra hash it the hash of the combination of uncles hash and the extension hash.
Source§impl<'r> Clone for BlockReader<'r>
impl<'r> Clone for BlockReader<'r>
Source§fn clone(&self) -> BlockReader<'r>
fn clone(&self) -> BlockReader<'r>
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<'r> Debug for BlockReader<'r>
impl<'r> Debug for BlockReader<'r>
Source§impl<'r> Display for BlockReader<'r>
impl<'r> Display for BlockReader<'r>
Source§impl<'r> LowerHex for BlockReader<'r>
impl<'r> LowerHex for BlockReader<'r>
Source§impl<'r> Reader<'r> for BlockReader<'r>
impl<'r> Reader<'r> for BlockReader<'r>
const NAME: &'static str = "BlockReader"
type Entity = Block
fn to_entity(&self) -> <BlockReader<'r> as Reader<'r>>::Entity
fn new_unchecked(slice: &'r [u8]) -> BlockReader<'r>
fn as_slice(&self) -> &'r [u8] ⓘ
fn verify(slice: &[u8], compatible: bool) -> Result<(), VerificationError>
fn from_slice(slice: &'r [u8]) -> Result<Self, VerificationError>
fn from_compatible_slice(slice: &'r [u8]) -> Result<Self, VerificationError>
impl<'r> Copy for BlockReader<'r>
Auto Trait Implementations§
impl<'r> Freeze for BlockReader<'r>
impl<'r> RefUnwindSafe for BlockReader<'r>
impl<'r> Send for BlockReader<'r>
impl<'r> Sync for BlockReader<'r>
impl<'r> Unpin for BlockReader<'r>
impl<'r> UnwindSafe for BlockReader<'r>
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
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<'r, R> FromSliceShouldBeOk<'r> for Rwhere
R: Reader<'r>,
impl<'r, R> FromSliceShouldBeOk<'r> for Rwhere
R: Reader<'r>,
Source§fn from_slice_should_be_ok(slice: &'r [u8]) -> R
fn from_slice_should_be_ok(slice: &'r [u8]) -> R
Unwraps the result of
from_slice(..)
with confidence and we assume that it’s impossible to fail.Source§fn from_compatible_slice_should_be_ok(slice: &'r [u8]) -> R
fn from_compatible_slice_should_be_ok(slice: &'r [u8]) -> R
Unwraps the result of
from_compatible_slice(..)
with confidence and we assume that it’s impossible to fail.