Struct Block

Source
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: BlockId

Consensus 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: SaitoHash

Non-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: SaitoHash

hash of block, combines pre_hash and previous_block_hash

§total_work: Currency

total routing work in block for block creator

§in_longest_chain: bool

is 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: bool

this block has a checkpoint. therefore we cannot reorg past this block.

Implementations§

Source§

impl Block

Source

pub fn new() -> Block

Source

pub fn add_transaction(&mut self, tx: Transaction)

Source

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>

Source

pub async fn delete(&self, utxoset: &mut UtxoSet) -> bool

Source

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]…

Source

pub async fn downgrade_block_to_block_type( &mut self, block_type: BlockType, _is_spv: bool, ) -> bool

downgrade block

Source

pub fn find_winning_router(&self, random_number: SaitoHash) -> SaitoPublicKey

Source

pub fn generate(&mut self) -> Result<(), Error>

Source

pub fn generate_hash(&mut self) -> SaitoHash

Source

pub fn generate_merkle_root(&self, is_browser: bool, is_spv: bool) -> SaitoHash

Source

pub async fn generate_consensus_values( &self, blockchain: &Blockchain, storage: &Storage, configs: &(dyn Configuration + Send + Sync), ) -> ConsensusValues

Source

pub fn generate_pre_hash(&mut self)

Source

pub fn on_chain_reorganization( &mut self, utxoset: &mut UtxoSet, longest_chain: bool, ) -> bool

Source

pub fn sign(&mut self, private_key: &SaitoPrivateKey)

Source

pub fn serialize_for_hash(&self) -> Vec<u8>

Source

pub fn serialize_for_signature(&self) -> Vec<u8>

Source

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]…

Source

pub async fn update_block_to_block_type( &mut self, block_type: BlockType, storage: &Storage, is_browser: bool, ) -> bool

Source

pub async fn upgrade_block_to_block_type( &mut self, block_type: BlockType, storage: &Storage, is_spv: bool, ) -> bool

Source

pub fn generate_lite_block(&self, keylist: Vec<SaitoPublicKey>) -> Block

Source

pub async fn validate( &self, blockchain: &Blockchain, utxoset: &UtxoSet, configs: &(dyn Configuration + Send + Sync), storage: &Storage, validate_against_utxo: bool, ) -> bool

Source

pub fn generate_transaction_hashmap(&mut self)

Source

pub fn has_keylist_txs(&self, keylist: &Vec<SaitoPublicKey>) -> bool

Source

pub fn get_file_name(&self) -> String

Source

pub fn print_all(&self)

Trait Implementations§

Source§

impl Clone for Block

Source§

fn clone(&self) -> Block

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Block

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Block

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Block

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Block

Source§

fn eq(&self, other: &Block) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Block

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Block

Auto Trait Implementations§

§

impl Freeze for Block

§

impl RefUnwindSafe for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnwindSafe for Block

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,