pub struct Block {Show 55 fields
pub id: BlockId,
pub timestamp: Timestamp,
pub previous_block_hash: [u8; 32],
pub creator: [u8; 33],
pub merkle_root: [u8; 32],
pub signature: [u8; 64],
pub graveyard: Currency,
pub treasury: Currency,
pub total_fees: Currency,
pub total_fees_new: Currency,
pub total_fees_atr: Currency,
pub total_fees_cumulative: Currency,
pub avg_total_fees: Currency,
pub avg_total_fees_new: Currency,
pub avg_total_fees_atr: Currency,
pub total_payout_routing: Currency,
pub total_payout_mining: Currency,
pub total_payout_treasury: Currency,
pub total_payout_graveyard: Currency,
pub total_payout_atr: Currency,
pub avg_payout_routing: Currency,
pub avg_payout_mining: Currency,
pub avg_payout_treasury: Currency,
pub avg_payout_graveyard: Currency,
pub avg_payout_atr: Currency,
pub avg_fee_per_byte: Currency,
pub fee_per_byte: Currency,
pub avg_nolan_rebroadcast_per_block: Currency,
pub burnfee: Currency,
pub difficulty: u64,
pub previous_block_unpaid: Currency,
pub transactions: Vec<Transaction>,
pub pre_hash: SaitoHash,
pub hash: SaitoHash,
pub total_work: Currency,
pub in_longest_chain: bool,
pub has_golden_ticket: bool,
pub has_issuance_transaction: bool,
pub issuance_transaction_index: u64,
pub has_fee_transaction: bool,
pub has_staking_transaction: bool,
pub golden_ticket_index: u64,
pub fee_transaction_index: u64,
pub total_rebroadcast_slips: u64,
pub total_rebroadcast_nolan: Currency,
pub rebroadcast_hash: [u8; 32],
pub block_type: BlockType,
pub cv: ConsensusValues,
pub slips_spent_this_block: AHashMap<SaitoUTXOSetKey, u64>,
pub created_hashmap_of_slips_spent_this_block: bool,
pub routed_from_peer: Option<PeerIndex>,
pub transaction_map: AHashMap<SaitoPublicKey, bool>,
pub force_loaded: bool,
pub safe_to_prune_transactions: bool,
pub has_checkpoint: bool,
}Fields§
§id: BlockIdConsensus Level Variables
these are the variables that are serialized into the block header and distributed with every block. validating a block requires confirming that all of these values are correct given the content in the block itself.
timestamp: Timestamp§previous_block_hash: [u8; 32]§creator: [u8; 33]§merkle_root: [u8; 32]§signature: [u8; 64]§graveyard: Currency§treasury: Currency§total_fees: Currency§total_fees_new: Currency§total_fees_atr: Currency§total_fees_cumulative: Currency§avg_total_fees: Currency§avg_total_fees_new: Currency§avg_total_fees_atr: Currency§total_payout_routing: Currency§total_payout_mining: Currency§total_payout_treasury: Currency§total_payout_graveyard: Currency§total_payout_atr: Currency§avg_payout_routing: Currency§avg_payout_mining: Currency§avg_payout_treasury: Currency§avg_payout_graveyard: Currency§avg_payout_atr: Currency§avg_fee_per_byte: Currency§fee_per_byte: Currency§avg_nolan_rebroadcast_per_block: Currency§burnfee: Currency§difficulty: u64§previous_block_unpaid: Currency§transactions: Vec<Transaction>Transactions
these are all of the transactions that are found a full-block. lite-blocks may only contain subsets of these transactions, which can be validated independently.
pre_hash: SaitoHashNon-Consensus Values
these values are needed when creating or validating a block but are generated from the block-data and are not included in the block-header and must be created by running block.generate() which fills in most of these values.
the pre_hash is the hash created from all of the contents of this block. it is then hashed with the previous_block_hash (in header) to generate the unique hash for this block. this hash is not incl. in the consensus variables as it can be independently generated.
hash: SaitoHashhash of block, combines pre_hash and previous_block_hash
total_work: Currencytotal routing work in block for block creator
in_longest_chain: boolis block on longest chain
has_golden_ticket: bool§has_issuance_transaction: bool§issuance_transaction_index: u64§has_fee_transaction: bool§has_staking_transaction: bool§golden_ticket_index: u64§fee_transaction_index: u64§total_rebroadcast_slips: u64§total_rebroadcast_nolan: Currency§rebroadcast_hash: [u8; 32]§block_type: BlockType§cv: ConsensusValues§slips_spent_this_block: AHashMap<SaitoUTXOSetKey, u64>§created_hashmap_of_slips_spent_this_block: bool§routed_from_peer: Option<PeerIndex>§transaction_map: AHashMap<SaitoPublicKey, bool>§force_loaded: bool§safe_to_prune_transactions: bool§has_checkpoint: boolthis block has a checkpoint. therefore we cannot reorg past this block.
Implementations§
Source§impl Block
impl Block
pub fn new() -> Block
pub fn add_transaction(&mut self, tx: Transaction)
pub async fn create( transactions: &mut AHashMap<SaitoSignature, Transaction>, previous_block_hash: SaitoHash, blockchain: &Blockchain, current_timestamp: Timestamp, public_key: &SaitoPublicKey, private_key: &SaitoPrivateKey, golden_ticket: Option<Transaction>, configs: &(dyn Configuration + Send + Sync), storage: &Storage, ) -> Result<Block, Error>
pub async fn delete(&self, utxoset: &mut UtxoSet) -> bool
Sourcepub fn deserialize_from_net(bytes: &[u8]) -> Result<Block, Error>
pub fn deserialize_from_net(bytes: &[u8]) -> Result<Block, Error>
Deserialize from bytes to a Block. [len of transactions - 4 bytes - u32] [id - 8 bytes - u64] [timestamp - 8 bytes - u64] [previous_block_hash - 32 bytes - SHA 256 hash] [creator - 33 bytes - Secp25k1 pubkey compact format] [merkle_root - 32 bytes - SHA 256 hash [signature - 64 bytes - Secp25k1 sig] [graveyard - 8 bytes - u64] [treasury - 8 bytes - u64] [burnfee - 8 bytes - u64] [difficulty - 8 bytes - u64] [avg_total_fees - 8 bytes - u64] [avg_fee_per_byte - 8 bytes - u64] [avg_nolan_rebroadcast_per_block - 8 bytes - u64] [previous_block_unpaid - 8 bytes - u64] [avg_total_fees - 8 bytes - u64] [avg_total_fees_new - 8 bytes - u64] [avg_total_fees_atr - 8 bytes - u64] [avg_payout_routing - 8 bytes - u64] [avg_payout_mining - 8 bytes - u64] [avg_payout_treasury - 8 bytes - u64] [avg_payout_graveyard - 8 bytes - u64] [avg_payout_atr - 8 bytes - u64] [total_payout_routing - 8 bytes - u64] [total_payout_mining - 8 bytes - u64] [total_payout_treasury - 8 bytes - u64] [total_payout_graveyard - 8 bytes - u64] [total_payout_atr - 8 bytes - u64] [total_fees - 8 bytes - u64] [total_fees_new - 8 bytes - u64] [total_fees_atr - 8 bytes - u64] [fee_per_byte - 8 bytes - u64] [total_fees_cumulative - 8 bytes - u64] [transaction][transaction][transaction]…
Sourcepub async fn downgrade_block_to_block_type(
&mut self,
block_type: BlockType,
_is_spv: bool,
) -> bool
pub async fn downgrade_block_to_block_type( &mut self, block_type: BlockType, _is_spv: bool, ) -> bool
downgrade block
pub fn find_winning_router(&self, random_number: SaitoHash) -> SaitoPublicKey
pub fn generate(&mut self) -> Result<(), Error>
pub fn generate_hash(&mut self) -> SaitoHash
pub fn generate_merkle_root(&self, is_browser: bool, is_spv: bool) -> SaitoHash
pub async fn generate_consensus_values( &self, blockchain: &Blockchain, storage: &Storage, configs: &(dyn Configuration + Send + Sync), ) -> ConsensusValues
pub fn generate_pre_hash(&mut self)
pub fn on_chain_reorganization( &mut self, utxoset: &mut UtxoSet, longest_chain: bool, ) -> bool
pub fn sign(&mut self, private_key: &SaitoPrivateKey)
pub fn serialize_for_hash(&self) -> Vec<u8> ⓘ
pub fn serialize_for_signature(&self) -> Vec<u8> ⓘ
Sourcepub fn serialize_for_net(&self, block_type: BlockType) -> Vec<u8> ⓘ
pub fn serialize_for_net(&self, block_type: BlockType) -> Vec<u8> ⓘ
Serialize a Block for transport or disk. [len of transactions - 4 bytes - u32] [id - 8 bytes - u64] [timestamp - 8 bytes - u64] [previous_block_hash - 32 bytes - SHA 256 hash] [creator - 33 bytes - Secp25k1 pubkey compact format] [merkle_root - 32 bytes - SHA 256 hash [signature - 64 bytes - Secp25k1 sig] [graveyard - 8 bytes - u64] [treasury - 8 bytes - u64] [burnfee - 8 bytes - u64] [difficulty - 8 bytes - u64] [avg_total_fees - 8 bytes - u64] [avg_fee_per_byte - 8 bytes - u64] [avg_nolan_rebroadcast_per_block - 8 bytes - u64] [previous_block_unpaid - 8 bytes - u64] [avg_total_fees - 8 bytes - u64] // note the duplicate here, is because added in group [avg_total_fees_new - 8 bytes - u64] [avg_total_fees_atr - 8 bytes - u64] [avg_payout_routing - 8 bytes - u64] [avg_payout_mining - 8 bytes - u64] [avg_payout_treasury - 8 bytes - u64] [avg_payout_graveyard - 8 bytes - u64] [avg_payout_atr - 8 bytes - u64] [total_fees - 8 bytes - u64] [total_fees_new - 8 bytes - u64] [total_fees_atr - 8 bytes - u64] [fee_per_byte - 8 bytes - u64] [total_fees_cumulative - 8 bytes - u64] [transaction][transaction][transaction]…