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]
impl Block
[src]pub fn new(
prev: &BlockHeader,
txs: &[Transaction],
difficulty: Difficulty,
reward_output: (Output, TxKernel)
) -> Result<Block, Error>
[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]
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]
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]
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]
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 total_fees(&self) -> u64
[src]
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]
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]
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]
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]
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]
fn inputs_committed(&self) -> Vec<Commitment>
[src]Vector of input commitments to verify.
fn outputs_committed(&self) -> Vec<Commitment>
[src]
fn outputs_committed(&self) -> Vec<Commitment>
[src]Vector of output commitments to verify.
fn kernels_committed(&self) -> Vec<Commitment>
[src]
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]
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]
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]
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 From<UntrustedBlock> for Block
[src]
impl From<UntrustedBlock> for Block
[src]fn from(block: UntrustedBlock) -> Self
[src]
fn from(block: UntrustedBlock) -> Self
[src]Performs the conversion.
impl Readable for Block
[src]
impl Readable for Block
[src]Implementation of Readable for a block, defines how to read a full block from a binary stream.
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[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,
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,
T: Send,
pub fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync, Global> where
T: Sync,
T: Sync,
pub fn clone_any_send_sync(
&self
) -> Box<dyn CloneAny + 'static + Sync + Send, Global> where
T: Send + Sync,
&self
) -> Box<dyn CloneAny + 'static + Sync + Send, Global> where
T: Send + Sync,
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<H> ShortIdentifiable for H where
H: Hashed,
[src]
impl<H> ShortIdentifiable for H where
H: Hashed,
[src]pub fn short_id(&Self, &Hash, u64) -> ShortId
[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]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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> DebugAny for T where
T: Any + Debug,
T: Any + Debug,
impl<T> UnsafeAny for T where
T: Any,
T: Any,