Struct grin_core::core::block::Block[][src]

pub struct Block {
    pub header: BlockHeader,
    pub body: TransactionBody,
}

A block as expressed in the Mimblewimble protocol. The reward is non-explicit, assumed to be deducible from block height (similar to bitcoin’s schedule) and expressed as a global transaction fee (added v.H), additive to the total of fees ever collected.

Fields

header: BlockHeader

The header with metadata and commitments to the rest of the data

body: TransactionBody

The body - inputs/outputs/kernels

Implementations

impl Block[src]

pub fn new(
    prev: &BlockHeader,
    txs: &[Transaction],
    difficulty: Difficulty,
    reward_output: (Output, TxKernel)
) -> Result<Block, Error>
[src]

Builds a new block from the header of the previous block, a vector of transactions and the private key that will receive the reward. Checks that all transactions are valid and calculates the Merkle tree.

TODO - Move this somewhere where only tests will use it. *** Only used in tests. ***

pub fn hydrate_from(
    cb: CompactBlock,
    txs: &[Transaction]
) -> Result<Block, Error>
[src]

Hydrate a block from a compact block. Note: caller must validate the block themselves, we do not validate it here.

pub fn with_header(header: BlockHeader) -> Block[src]

Build a new empty block from a specified header

pub fn from_reward(
    prev: &BlockHeader,
    txs: &[Transaction],
    reward_out: Output,
    reward_kern: TxKernel,
    difficulty: Difficulty
) -> Result<Block, Error>
[src]

Builds a new block ready to mine from the header of the previous block, a vector of transactions and the reward information. Checks that all transactions are valid and calculates the Merkle tree.

pub fn with_reward(self, reward_out: Output, reward_kern: TxKernel) -> Block[src]

Consumes this block and returns a new block with the coinbase output and kernels added

pub fn inputs(&self) -> Inputs[src]

Get inputs

pub fn outputs(&self) -> &[Output][src]

Get outputs

pub fn kernels(&self) -> &[TxKernel][src]

Get kernels

pub fn total_fees(&self) -> u64[src]

Sum of all fees (inputs less outputs) in the block

pub fn validate_read(&self) -> Result<(), Error>[src]

“Lightweight” validation that we can perform quickly during read/deserialization. Subset of full validation that skips expensive verification steps, specifically -

  • rangeproof verification (on the body)
  • kernel signature verification (on the body)
  • coinbase sum verification
  • kernel sum verification

pub fn validate(&self, prev_kernel_offset: &BlindingFactor) -> Result<(), Error>[src]

Validates all the elements in a block that can be checked without additional data. Includes commitment sums and kernels, Merkle trees, reward, etc.

pub fn verify_coinbase(&self) -> Result<(), Error>[src]

Validate the coinbase.body.outputs generated by miners. Check the sum of coinbase-marked outputs match the sum of coinbase-marked kernels accounting for fees.

Trait Implementations

impl Clone for Block[src]

fn clone(&self) -> Block[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Committed for Block[src]

Provides all information from a block that allows the calculation of total Pedersen commitment.

fn inputs_committed(&self) -> Vec<Commitment>[src]

Vector of input commitments to verify.

fn outputs_committed(&self) -> Vec<Commitment>[src]

Vector of output commitments to verify.

fn kernels_committed(&self) -> Vec<Commitment>[src]

Vector of kernel excesses to verify.

fn sum_kernel_excesses(
    &self,
    offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]

Gather the kernel excesses and sum them.

fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>[src]

Gathers commitments and sum them.

fn verify_kernel_sums(
    &self,
    overage: i64,
    kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]

Verify the sum of the kernel excesses equals the sum of the outputs, taking into account both the kernel_offset and overage. Read more

impl Debug for Block[src]

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

Formats the value using the given formatter. Read more

impl Default for Block[src]

Default properties for a block, everything zeroed out and empty vectors.

fn default() -> Block[src]

Returns the “default value” for a type. Read more

impl From<Block> for CompactBlock[src]

fn from(block: Block) -> Self[src]

Performs the conversion.

impl From<UntrustedBlock> for Block[src]

fn from(block: UntrustedBlock) -> Self[src]

Performs the conversion.

impl Hashed for Block[src]

fn hash(&self) -> Hash[src]

The hash of the underlying block.

impl Readable for Block[src]

Implementation of Readable for a block, defines how to read a full block from a binary stream.

fn read<R: Reader>(reader: &mut R) -> Result<Block, Error>[src]

Reads the data necessary to this Readable from the provided reader

impl Serialize for Block[src]

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl Writeable for Block[src]

Implementation of Writeable for a block, defines how to write the block to a binary writer. Differentiates between writing the block for the purpose of full serialization and the one of just extracting a hash.

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>[src]

Write the data held by this Writeable to the provided writer

Auto Trait Implementations

impl RefUnwindSafe for Block

impl Send for Block

impl Sync for Block

impl Unpin for Block

impl UnwindSafe for Block

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CloneAny for T where
    T: Any + Clone

pub fn clone_any(&self) -> Box<dyn CloneAny + 'static, Global>

pub fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send, Global> where
    T: Send

pub fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync, Global> where
    T: Sync

pub fn clone_any_send_sync(
    &self
) -> Box<dyn CloneAny + 'static + Sync + Send, Global> where
    T: Send + Sync

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<H> ShortIdentifiable for H where
    H: Hashed
[src]

pub fn short_id(&Self, &Hash, u64) -> ShortId[src]

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> UnsafeAny for T where
    T: Any