Struct Block

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

Implementations§

Source§

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

Source

pub const NUM_GENESIS_TRANSACTIONS: usize = 4usize

Specifies the number of genesis transactions.

Source

pub fn is_genesis(&self) -> bool

Returns true if the block is a genesis block.

Source§

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

Source

pub fn verify( &self, previous_block: &Block<N>, current_state_root: <N as Network>::StateRoot, current_committee: &Committee<N>, current_puzzle: &CoinbasePuzzle<N>, current_epoch_challenge: &EpochChallenge<N>, current_timestamp: i64, ratified_finalize_operations: Vec<FinalizeOperation<N>>, ) -> Result<Vec<<N as Network>::TransactionID>, Error>

Ensures the block is correct.

Source§

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

Source

pub fn new_beacon<R>( private_key: &PrivateKey<N>, previous_hash: <N as Network>::BlockHash, header: Header<N>, ratifications: Ratifications<N>, solutions: Option<CoinbaseSolution<N>>, transactions: Transactions<N>, aborted_transaction_ids: Vec<<N as Network>::TransactionID>, rng: &mut R, ) -> Result<Block<N>, Error>
where R: Rng + CryptoRng,

Initializes a new beacon block from the given previous block hash, block header, ratifications, solutions, transactions, and aborted transaction IDs.

Source

pub fn new_quorum( previous_hash: <N as Network>::BlockHash, header: Header<N>, subdag: Subdag<N>, ratifications: Ratifications<N>, solutions: Option<CoinbaseSolution<N>>, transactions: Transactions<N>, aborted_transaction_ids: Vec<<N as Network>::TransactionID>, ) -> Result<Block<N>, Error>

Initializes a new quorum block from the given previous block hash, block header, subdag, ratifications, solutions, transactions, and aborted transaction IDs.

Source

pub fn from( previous_hash: <N as Network>::BlockHash, header: Header<N>, authority: Authority<N>, ratifications: Ratifications<N>, solutions: Option<CoinbaseSolution<N>>, transactions: Transactions<N>, aborted_transaction_ids: Vec<<N as Network>::TransactionID>, ) -> Result<Block<N>, Error>

Initializes a new block from the given previous block hash, block header, authority, ratifications, solutions, transactions, and aborted transaction IDs.

Source

pub fn from_unchecked( block_hash: <N as Network>::BlockHash, previous_hash: <N as Network>::BlockHash, header: Header<N>, authority: Authority<N>, ratifications: Ratifications<N>, solutions: Option<CoinbaseSolution<N>>, transactions: Transactions<N>, aborted_transaction_ids: Vec<<N as Network>::TransactionID>, ) -> Result<Block<N>, Error>

Initializes a new block from the given block hash, previous block hash, block header, authority, ratifications, solutions, transactions, and aborted transaction IDs.

Source§

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

Source

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

Returns the block hash.

Source

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

Returns the previous block hash.

Source

pub const fn authority(&self) -> &Authority<N>

Returns the authority.

Source

pub const fn ratifications(&self) -> &Ratifications<N>

Returns the ratifications in this block.

Source

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

Returns the solutions in the block.

Source

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

Returns the transactions in this block.

Source

pub const fn aborted_transaction_ids( &self, ) -> &Vec<<N as Network>::TransactionID>

Returns the aborted transaction IDs in this block.

Source§

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

Source

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

Returns the block header.

Source

pub const fn previous_state_root(&self) -> <N as Network>::StateRoot

Returns the previous state root from the block header.

Source

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

Returns the transactions root in the block header.

Source

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

Returns the finalize root in the block header.

Source

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

Returns the ratifications root in the block header.

Source

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

Returns the solutions root in the block header.

Source

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

Returns the metadata in the block header.

Source

pub const fn network(&self) -> u16

Returns the network ID of this block.

Source

pub const fn height(&self) -> u32

Returns the height of this block.

Source

pub const fn round(&self) -> u64

Returns the round number of this block.

Source

pub const fn epoch_number(&self) -> u32

Returns the epoch number of this block.

Source

pub const fn cumulative_weight(&self) -> u128

Returns the cumulative weight for this block.

Source

pub const fn cumulative_proof_target(&self) -> u128

Returns the cumulative proof target for this block.

Source

pub const fn coinbase_target(&self) -> u64

Returns the coinbase target for this block.

Source

pub const fn proof_target(&self) -> u64

Returns the proof target for this block.

Source

pub const fn last_coinbase_target(&self) -> u64

Returns the coinbase target of the last coinbase.

Source

pub const fn last_coinbase_timestamp(&self) -> i64

Returns the block timestamp of the last coinbase.

Source

pub const fn timestamp(&self) -> i64

Returns the Unix timestamp (UTC) for this block.

Source§

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

Source

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

Returns true if the block contains the given transition ID.

Source

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

Returns true if the block contains the given serial number.

Source

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

Returns true if the block contains the given commitment.

Source§

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

Source

pub fn get_solution( &self, puzzle_commitment: &PuzzleCommitment<N>, ) -> Option<&ProverSolution<N>>

Returns the solution with the given solution ID, if it exists.

Source

pub fn get_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Option<&Transaction<N>>

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

Source

pub fn get_confirmed_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Option<&ConfirmedTransaction<N>>

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

Source§

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

Source

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.

Source

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.

Source

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

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

Source

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.

Source

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.

Source

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

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

Source

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

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

Source§

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

Source

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

Returns the puzzle commitments in this block.

Source

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

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

Source

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

Returns an iterator over all transactions in self that are accepted deploy transactions.

Source

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

Returns an iterator over all transactions in self that are accepted execute transactions.

Source

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

Returns an iterator over all transitions.

Source

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

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

Source

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

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

Source

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

Returns an iterator over the transition commitments, for all transactions.

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

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.

Source

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

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

Source

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

Returns an iterator over the transaction fee amounts, for all transactions.

Source§

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

Source

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.

Source

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

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

Source

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

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

Source

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

Returns a consuming iterator over all transitions.

Source

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

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

Source

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

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

Source

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

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

Source

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.

Source

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

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

Source

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.

Source

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§

Source§

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

Source§

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

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

Source§

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

Prints the block as a JSON-string.

Source§

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

Source§

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.

Source§

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

Source§

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

Displays the block as a JSON-string.

Source§

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

Source§

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

Reads the block from the buffer.

Source§

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> FromStr for Block<N>
where N: Network,

Source§

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

Initializes the block from a JSON-string.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl<N> PartialEq for Block<N>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

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.

Source§

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

Source§

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

Writes the block to the buffer.

Source§

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 for Block<N>
where N: Eq + Network, <N as Network>::BlockHash: Eq, <N as Network>::TransactionID: Eq,

Source§

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

Auto Trait Implementations§

§

impl<N> Freeze for Block<N>

§

impl<N> RefUnwindSafe for Block<N>

§

impl<N> Send for Block<N>

§

impl<N> Sync for Block<N>

§

impl<N> Unpin for Block<N>

§

impl<N> UnwindSafe for Block<N>

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

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Source§

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

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

impl<Q, K> Equivalent<K> for Q
where 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.
Source§

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

Source§

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

Source§

impl<T> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T