[−][src]Struct grin_core::core::block::Block
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
Implementations
impl Block
[src]
pub fn new(
prev: &BlockHeader,
txs: Vec<Transaction>,
difficulty: Difficulty,
reward_output: (Output, TxKernel)
) -> Result<Block, Error>
[src]
prev: &BlockHeader,
txs: Vec<Transaction>,
difficulty: Difficulty,
reward_output: (Output, TxKernel)
) -> Result<Block, Error>
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]
cb: CompactBlock,
txs: Vec<Transaction>
) -> Result<Block, Error>
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]
prev: &BlockHeader,
txs: Vec<Transaction>,
reward_out: Output,
reward_kern: TxKernel,
difficulty: Difficulty
) -> Result<Block, Error>
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]
&self,
prev_kernel_offset: &BlindingFactor,
verifier: Arc<RwLock<dyn VerifierCache>>
) -> Result<Commitment, Error>
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]
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 outputs_committed(&self) -> Vec<Commitment>
[src]
fn kernels_committed(&self) -> Vec<Commitment>
[src]
fn sum_kernel_excesses(
&self,
offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]
&self,
offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>
[src]
fn verify_kernel_sums(
&self,
overage: i64,
kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]
&self,
overage: i64,
kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
impl Debug for Block
[src]
impl Default for Block
[src]
Default properties for a block, everything zeroed out and empty vectors.
impl From<Block> for CompactBlock
[src]
impl From<UntrustedBlock> for Block
[src]
fn from(block: UntrustedBlock) -> Self
[src]
impl Hashed 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.
impl Serialize for Block
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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.
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
T: Any + Debug,
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<D> Hashed for D where
D: DefaultHashable,
[src]
D: DefaultHashable,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<H> ShortIdentifiable for H where
H: Hashed,
[src]
H: Hashed,
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]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> UnsafeAny for T where
T: Any,
T: Any,