pub struct Block {
pub header: Arc<Header>,
pub transactions: Arc<Vec<Transaction>>,
}Expand description
A block structure where the inner header and transactions are wrapped by Arcs for cheap cloning and for cross-thread safety and immutability. Note: no need to wrap this struct with an additional Arc.
Fields§
§header: Arc<Header>§transactions: Arc<Vec<Transaction>>Implementations§
Source§impl Block
impl Block
pub fn new(header: Header, txs: Vec<Transaction>) -> Self
pub fn from_arcs( header: Arc<Header>, transactions: Arc<Vec<Transaction>>, ) -> Self
pub fn from_header_arc(header: Arc<Header>) -> Self
pub fn from_header(header: Header) -> Self
pub fn is_header_only(&self) -> bool
pub fn hash(&self) -> Hash
Sourcepub fn from_precomputed_hash(hash: Hash, parents: Vec<Hash>) -> Block
pub fn from_precomputed_hash(hash: Hash, parents: Vec<Hash>) -> Block
WARNING: To be used for test purposes only
pub fn asses_for_cache(&self) -> Option<()>
Trait Implementations§
Source§impl From<&GenesisBlock> for Block
impl From<&GenesisBlock> for Block
Source§fn from(genesis: &GenesisBlock) -> Self
fn from(genesis: &GenesisBlock) -> Self
Converts to this type from the input type.
Source§impl MemSizeEstimator for Block
impl MemSizeEstimator for Block
Source§fn estimate_mem_bytes(&self) -> usize
fn estimate_mem_bytes(&self) -> usize
Estimates the (deep) size of this object in bytes (including heap owned inner data)
Source§fn estimate_size(&self, mem_mode: MemMode) -> usize
fn estimate_size(&self, mem_mode: MemMode) -> usize
Estimates the size of this object depending on the passed mem mode
Source§fn estimate_mem_units(&self) -> usize
fn estimate_mem_units(&self) -> usize
Estimates the number of units this object holds in memory where the unit byte size is usually
a constant known to the caller as well (and hence we avoid computing it over and over)
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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>
Converts
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>
Converts
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