pub struct Block<N>where
    N: Network,{ /* private fields */ }

Implementations§

§

impl<N> Block<N>where N: Network,

pub fn genesis<C, R>( vm: &VM<N, C>, private_key: &PrivateKey<N>, rng: &mut R ) -> Result<Block<N>, Error>where C: ConsensusStorage<N>, R: Rng + CryptoRng,

Initializes a new genesis block.

pub fn is_genesis(&self) -> bool

Returns true if the block is a genesis block.

§

impl<N> Block<N>where N: Network,

pub fn new<R>( private_key: &PrivateKey<N>, previous_hash: <N as Network>::BlockHash, header: Header<N>, transactions: Transactions<N>, coinbase: Option<CoinbaseSolution<N>>, rng: &mut R ) -> Result<Block<N>, Error>where R: Rng + CryptoRng,

Initializes a new block from a given previous hash, header, transactions, coinbase, and signature.

pub fn from( previous_hash: <N as Network>::BlockHash, header: Header<N>, transactions: Transactions<N>, coinbase: Option<CoinbaseSolution<N>>, signature: Signature<N> ) -> Result<Block<N>, Error>

Initializes a new block from a given previous hash, header, transactions, coinbase, and signature.

§

impl<N> Block<N>where N: Network,

pub const fn hash(&self) -> <N as Network>::BlockHash

Returns the block hash.

pub const fn previous_hash(&self) -> <N as Network>::BlockHash

Returns the previous block hash.

pub const fn coinbase(&self) -> Option<&CoinbaseSolution<N>>

Returns the coinbase solution.

pub const fn signature(&self) -> &Signature<N>

Returns the signature.

§

impl<N> Block<N>where N: Network,

pub const fn header(&self) -> &Header<N>

Returns the block header.

pub const fn previous_state_root(&self) -> Field<N>

Returns the previous state root from the block header.

pub const fn transactions_root(&self) -> Field<N>

Returns the transactions root in the block header.

pub const fn finalize_root(&self) -> Field<N>

Returns the finalize root in the block header.

pub const fn metadata(&self) -> &Metadata<N>

Returns the metadata in the block header.

pub const fn network(&self) -> u16

Returns the network ID of this block.

pub const fn height(&self) -> u32

Returns the height of this block.

pub const fn round(&self) -> u64

Returns the round number of this block.

pub const fn epoch_number(&self) -> u32

Returns the epoch number of this block.

pub const fn total_supply_in_microcredits(&self) -> u64

Returns the total supply of microcredits at this block.

pub const fn cumulative_proof_target(&self) -> u128

Returns the cumulative proof target for this block.

pub const fn coinbase_target(&self) -> u64

Returns the coinbase target for this block.

pub const fn proof_target(&self) -> u64

Returns the proof target for this block.

pub const fn last_coinbase_target(&self) -> u64

Returns the coinbase target of the last coinbase.

pub const fn last_coinbase_timestamp(&self) -> i64

Returns the Unix timestamp (UTC) of the last coinbase.

pub const fn timestamp(&self) -> i64

Returns the Unix timestamp (UTC) for this block.

§

impl<N> Block<N>where N: Network,

pub fn contains_transition( &self, transition_id: &<N as Network>::TransitionID ) -> bool

Returns true if the block contains the given transition ID.

pub fn contains_serial_number(&self, serial_number: &Field<N>) -> bool

Returns true if the block contains the given serial number.

pub fn contains_commitment(&self, commitment: &Field<N>) -> bool

Returns true if the block contains the given commitment.

§

impl<N> Block<N>where N: Network,

pub fn find_transaction_for_transition_id( &self, transition_id: &<N as Network>::TransitionID ) -> Option<&Transaction<N>>

Returns the transaction with the given transition ID, if it exists.

pub fn find_transaction_for_serial_number( &self, serial_number: &Field<N> ) -> Option<&Transaction<N>>

Returns the transaction with the given serial number, if it exists.

pub fn find_transaction_for_commitment( &self, commitment: &Field<N> ) -> Option<&Transaction<N>>

Returns the transaction with the given commitment, if it exists.

pub fn find_transition( &self, transition_id: &<N as Network>::TransitionID ) -> Option<&Transition<N>>

Returns the transition with the corresponding transition ID, if it exists.

pub fn find_transition_for_serial_number( &self, serial_number: &Field<N> ) -> Option<&Transition<N>>

Returns the transition for the given serial number, if it exists.

pub fn find_transition_for_commitment( &self, commitment: &Field<N> ) -> Option<&Transition<N>>

Returns the transition for the given commitment, if it exists.

pub fn find_record( &self, commitment: &Field<N> ) -> Option<&Record<N, Ciphertext<N>>>

Returns the record with the corresponding commitment, if it exists.

§

impl<N> Block<N>where N: Network,

pub fn puzzle_commitments( &self ) -> Option<impl Iterator<Item = PuzzleCommitment<N>>>

Returns the puzzle commitments in this block.

pub const fn transactions(&self) -> &Transactions<N>

Returns the transactions in this block.

pub fn transaction_ids( &self ) -> impl Iterator<Item = &<N as Network>::TransactionID>

Returns an iterator over the transaction IDs, for all transactions in self.

pub fn deployments(&self) -> impl Iterator<Item = &Deployment<N>>

Returns an iterator over all transactions in self that are deployments.

pub fn executions(&self) -> impl Iterator<Item = &Execution<N>>

Returns an iterator over all transactions in self that are executions.

pub fn transitions(&self) -> impl Iterator<Item = &Transition<N>>

Returns an iterator over all transitions.

pub fn transition_ids( &self ) -> impl Iterator<Item = &<N as Network>::TransitionID>

Returns an iterator over the transition IDs, for all transitions.

pub fn transition_public_keys(&self) -> impl Iterator<Item = &Group<N>>

Returns an iterator over the transition public keys, for all transactions.

pub fn tags(&self) -> impl Iterator<Item = &Field<N>>

Returns an iterator over the tags, for all transition inputs that are records.

pub fn serial_numbers(&self) -> impl Iterator<Item = &Field<N>>

Returns an iterator over the serial numbers, for all transition inputs that are records.

pub fn commitments(&self) -> impl Iterator<Item = &Field<N>>

Returns an iterator over the commitments, for all transition outputs that are records.

pub fn records( &self ) -> impl Iterator<Item = (&Field<N>, &Record<N, Ciphertext<N>>)>

Returns an iterator over the records, for all transition outputs that are records.

pub fn nonces(&self) -> impl Iterator<Item = &Group<N>>

Returns an iterator over the nonces, for all transition outputs that are records.

pub fn transaction_fees( &self ) -> impl Iterator<Item = Result<Integer<N, u64>, Error>>

Returns an iterator over the transaction fees, for all transactions.

§

impl<N> Block<N>where N: Network,

pub fn into_transaction_ids( self ) -> impl Iterator<Item = <N as Network>::TransactionID>

Returns a consuming iterator over the transaction IDs, for all transactions in self.

pub fn into_deployments(self) -> impl Iterator<Item = Deployment<N>>

Returns a consuming iterator over all transactions in self that are deployments.

pub fn into_executions(self) -> impl Iterator<Item = Execution<N>>

Returns a consuming iterator over all transactions in self that are executions.

pub fn into_transitions(self) -> impl Iterator<Item = Transition<N>>

Returns a consuming iterator over all transitions.

pub fn into_transition_ids( self ) -> impl Iterator<Item = <N as Network>::TransitionID>

Returns a consuming iterator over the transition IDs, for all transitions.

pub fn into_transition_public_keys(self) -> impl Iterator<Item = Group<N>>

Returns a consuming iterator over the transition public keys, for all transactions.

pub fn into_tags(self) -> impl Iterator<Item = Field<N>>

Returns a consuming iterator over the tags, for all transition inputs that are records.

pub fn into_serial_numbers(self) -> impl Iterator<Item = Field<N>>

Returns a consuming iterator over the serial numbers, for all transition inputs that are records.

pub fn into_commitments(self) -> impl Iterator<Item = Field<N>>

Returns a consuming iterator over the commitments, for all transition outputs that are records.

pub fn into_records( self ) -> impl Iterator<Item = (Field<N>, Record<N, Ciphertext<N>>)>

Returns a consuming iterator over the records, for all transition outputs that are records.

pub fn into_nonces(self) -> impl Iterator<Item = Group<N>>

Returns a consuming iterator over the nonces, for all transition outputs that are records.

Trait Implementations§

§

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

§

fn clone(&self) -> Block<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
§

impl<N> Debug for Block<N>where N: Network,

§

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

Prints the block as a JSON-string.

§

impl<'de, N> Deserialize<'de> for Block<N>where N: Network,

§

fn deserialize<D>( deserializer: D ) -> Result<Block<N>, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

Deserializes the block from a JSON-string or buffer.

§

impl<N> Display for Block<N>where N: Network,

§

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

Displays the block as a JSON-string.

§

impl<N> FromBytes for Block<N>where N: Network,

§

fn read_le<R>(reader: R) -> Result<Block<N>, Error>where R: Read,

Reads the block from the buffer.

§

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

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

impl<N> FromStr for Block<N>where N: Network,

§

fn from_str(block: &str) -> Result<Block<N>, <Block<N> as FromStr>::Err>

Initializes the block from a JSON-string.

§

type Err = Error

The associated error which can be returned from parsing.
§

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

§

fn eq(&self, other: &Block<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.
§

impl<N> Serialize for Block<N>where N: Network,

§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

Serializes the block to a JSON-string or buffer.

§

impl<N> ToBytes for Block<N>where N: Network,

§

fn write_le<W>(&self, writer: W) -> Result<(), Error>where W: Write,

Writes the block to the buffer.

§

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

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

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

§

impl<N> StructuralEq for Block<N>where N: Network,

§

impl<N> StructuralPartialEq for Block<N>where N: Network,

Auto Trait Implementations§

§

impl<N> RefUnwindSafe for Block<N>where N: RefUnwindSafe, <N as Network>::BlockHash: RefUnwindSafe, <N as Environment>::Field: RefUnwindSafe, <<N as Environment>::PairingCurve as PairingEngine>::G1Affine: RefUnwindSafe, <<N as Environment>::PairingCurve as PairingEngine>::G2Affine: RefUnwindSafe, <<<N as Environment>::PairingCurve as PairingEngine>::G2Affine as PairingCurve>::Prepared: RefUnwindSafe, <N as Environment>::Projective: RefUnwindSafe, <N as Environment>::Scalar: RefUnwindSafe, <N as Network>::StateRoot: RefUnwindSafe, <N as Network>::TransactionID: RefUnwindSafe, <N as Network>::TransitionID: RefUnwindSafe,

§

impl<N> Send for Block<N>

§

impl<N> Sync for Block<N>

§

impl<N> Unpin for Block<N>where N: Unpin, <N as Network>::BlockHash: Unpin, <N as Environment>::Field: Unpin, <<N as Environment>::PairingCurve as PairingEngine>::G1Affine: Unpin, <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin, <N as Network>::StateRoot: Unpin, <N as Network>::TransactionID: Unpin, <N as Network>::TransitionID: Unpin,

§

impl<N> UnwindSafe for Block<N>where N: UnwindSafe, <N as Network>::BlockHash: UnwindSafe, <N as Environment>::Field: UnwindSafe + RefUnwindSafe, <<N as Environment>::PairingCurve as PairingEngine>::G1Affine: UnwindSafe + RefUnwindSafe, <<N as Environment>::PairingCurve as PairingEngine>::G2Affine: RefUnwindSafe, <<<N as Environment>::PairingCurve as PairingEngine>::G2Affine as PairingCurve>::Prepared: RefUnwindSafe, <N as Environment>::Projective: UnwindSafe, <N as Environment>::Scalar: UnwindSafe, <N as Network>::StateRoot: UnwindSafe, <N as Network>::TransactionID: UnwindSafe, <N as Network>::TransitionID: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

source§

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

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

impl<Q, K> Equivalent<K> for Qwhere 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
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 Twhere 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 = mem::align_of::<T>()

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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere 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 Twhere T: for<'de> Deserialize<'de>,