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

pub struct Block {
    pub header: BlockHeader,
    // some fields omitted
}

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

Methods

impl Block[src]

pub fn new(
    prev: &BlockHeader,
    txs: Vec<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: Vec<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: Vec<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) -> &Vec<Input>[src]

Get inputs

pub fn inputs_mut(&mut self) -> &mut Vec<Input>[src]

Get inputs mutable

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

Get outputs

pub fn outputs_mut(&mut self) -> &mut Vec<Output>[src]

Get outputs mutable

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

Get kernels

pub fn kernels_mut(&mut self) -> &mut Vec<TxKernel>[src]

Get kernels mut

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

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

pub fn cut_through(self) -> Result<Block, Error>[src]

Matches any output with a potential spending input, eliminating them from the block. Provides a simple way to cut-through the block. The elimination is stable with respect to the order of inputs and outputs. Method consumes 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,
    verifier: Arc<RwLock<dyn VerifierCache>>
) -> Result<Commitment, 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 Committed for Block[src]

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

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 Hashed for Block[src]

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

The hash of the underlying block.

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.

impl Readable for Block[src]

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

impl Default for Block[src]

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

impl From<Block> for CompactBlock[src]

impl Clone for Block[src]

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

Performs copy-assignment from source. Read more

impl Debug for Block[src]

impl Serialize for Block[src]

Auto Trait Implementations

impl Send for Block

impl Unpin for Block

impl Sync for Block

impl UnwindSafe for Block

impl RefUnwindSafe for Block

Blanket Implementations

impl<D> Hashed for D where
    D: DefaultHashable
[src]

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

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.

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

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

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.

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.

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

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

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

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

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

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T