Struct libyobicash::models::block::Block
[−]
[src]
pub struct Block { pub id: Digest, pub version: Version, pub network_type: NetworkType, pub timestamp: Timestamp, pub transactions_size: u32, pub transactions_length: u32, pub transactions_ids: Vec<Digest>, }
A Block
is a commitment of validated transactions.
Fields
id: Digest
The block id.
version: Version
The version of the library.
network_type: NetworkType
The protocol network type.
timestamp: Timestamp
The unix timestamp of the time the block.
transactions_size: u32
The size of the block transactions.
transactions_length: u32
The length of the block transactions.
transactions_ids: Vec<Digest>
The block transactions' ids.
Methods
impl Block
[src]
pub fn new(
network_type: NetworkType,
transactions: &[Transaction]
) -> Result<Block>
[src]
network_type: NetworkType,
transactions: &[Transaction]
) -> Result<Block>
Creates a new Block
.
pub fn new_genesis(
version: &Version,
network_type: NetworkType,
genesis_witness: Option<ZKPWitness>
) -> Result<Block>
[src]
version: &Version,
network_type: NetworkType,
genesis_witness: Option<ZKPWitness>
) -> Result<Block>
Creates a new genesis Block
.
pub fn new_regtest_genesis(genesis_witness: ZKPWitness) -> Result<Block>
[src]
Creates a new regtest genesis Block
.
pub fn new_testnet_genesis() -> Result<Block>
[src]
Creates a new testnet genesis Block
.
pub fn new_mainnet_genesis() -> Result<Block>
[src]
Creates a new mainnet genesis Block
.
pub fn is_genesis(&self) -> Result<bool>
[src]
Verifies if the Block
is a genesis.
pub fn size(&self) -> Result<u32>
[src]
Returns the size of the Block
.
Trait Implementations
impl Clone for Block
[src]
fn clone(&self) -> Block
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for Block
[src]
fn eq(&self, __arg_0: &Block) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Block) -> bool
[src]
This method tests for !=
.
impl Debug for Block
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for Block
[src]
impl<'a> Identify<'a> for Block
[src]
type ID = Digest
Type of the identifier.
fn id(&self) -> Result<Self::ID>
[src]
Returns the ID
of the implementor.
fn id_from_bytes(b: &[u8]) -> Result<Self::ID>
[src]
Converts a binary to an ID
.
fn id_to_bytes(id: Self::ID) -> Result<Vec<u8>>
[src]
Converts an ID
to bytes.
fn binary_id(&self) -> Result<Vec<u8>>
[src]
Returns the binary representation of the ID
of the object.
fn id_from_string(s: &str) -> Result<Self::ID>
[src]
Converts a string to an ID
.
fn id_to_string(id: Self::ID) -> Result<String>
[src]
Converts an ID
to string.
fn string_id(&self) -> Result<String>
[src]
Returns the string representation of the ID
of the object.
impl Validate for Block
[src]
impl<'a> Serialize<'a> for Block
[src]
fn to_json(&self) -> Result<String>
[src]
Serialize to a json string.
fn from_json(s: &str) -> Result<Self>
[src]
Deserialize from a json string.
fn to_bytes(&self) -> Result<Vec<u8>>
[src]
Serialize to a binary.
fn from_bytes(b: &[u8]) -> Result<Self>
[src]
Deserialize from a binary.
fn to_hex(&self) -> Result<String>
[src]
Serialize to a hex.
fn from_hex(s: &str) -> Result<Self>
[src]
Deserialize from a hex.