Ixian SDK
DLT.Block Class Reference

An Ixian DLT Block. A block contains all the transactions which act on the WalletState and various checksums which validate the actions performed on the blockchain. Blocks are the fundamental data structure of Distributed Ledger Technology (DLT) and form a chain of valid states from the so-called 'Genesis Block' to the present moment. An Ixian Block must include checksums of the previous block, checksums of the internal data structures (WalletState) and a list of transactions which have updated the WalletState from its previous value to its current value. In addition, a block contains cryptographic signatures of Master nodes, which is the basis for the Ixian Consensus algorithm. More...

Public Member Functions

 Block ()
 
 Block (Block block)
 Copies the given block rather than making a reference to it. More...
 
 Block (byte[] bytes)
 Reconstructs a Block from the bytestream. See also getBytes. More...
 
byte [] getBytes ()
 Retrieves the block in its serialized, 'byte stream' format. See also Block(byte[] bytes). More...
 
bool Equals (Block b)
 Implementation of block equality. More...
 
bool addTransaction (string txid)
 Adds an Ixian Transaction to the block. The transaction must already be present in the TransactionPool. More...
 
byte [] calculateChecksum ()
 Calculates the blockChecksum of the DLT Block, using the relevant fields. More...
 
byte [] calculateSignatureChecksum ()
 Calculates the checksum of all signatures on this block. More...
 
byte [][] applySignature ()
 Signs the Block with the running DLT Master Node's private key. More...
 
bool containsSignature (byte[] address_or_pub_key)
 Checks if the block's signatures field contains the signature of the specified node. Either the node's address or its public key is accepted. More...
 
List< byte[][]> addSignaturesFrom (Block other)
 Mergest the signatures of two blocks without duplicating. More...
 
bool verifySignature (byte[] signature, byte[] signer_pub_key)
 Verifies if the given signature is valid for this block. More...
 
bool addSignature (byte[] signature, byte[] address_or_pub_key)
 Adds the provided signature to the block's signature list. More...
 
byte [] getSignerPubKey (byte[] address_or_pub_key)
 Attempts to retrieve the public key of the signer address. More...
 
bool verifySignatures (bool skip_sig_verification=false)
 Verifies that all signatures on this block are valid. More...
 
bool hasNodeSignature (byte[] public_key=null)
 Checks the signatures on the block and returns true, if the block has already been signed by the given public key. More...
 
List< byte[]> getSignaturesWalletAddresses (bool convert_pubkeys=true)
 Retrieves a list of Ixian Wallet addresses from the list of signatures on this block. More...
 
int getSignatureCount ()
 Retrives the number of signatures on this block. This function might return a larger value, because it does not check for potential duplicates. More...
 
int getUniqueSignatureCount ()
 Retrieves the number of unique signatures on the block. Signatures are verified so that only unique ones are included. More...
 
void setWalletStateChecksum (byte[] checksum)
 Allocates and sets the walletStateChecksum. More...
 
bool pruneSignatures ()
 ? More...
 
bool compact ()
 Removes the signatures as part of the compaction process (superblock functionality). More...
 
void logBlockDetails ()
 Writes the block's details to the log for debugging purposes. More...
 

Public Attributes

List< string > transactions = new List<string> { }
 The list of transactions which should act on the WalletState from the previous block to produce the WalletState for this block. More...
 
List< byte[][]> signatures = new List<byte[][]> { }
 The list of Master Node signatures which enable the Ixian Consensus algorithm. More...
 
int version = 0
 Block version. More...
 
byte [] blockChecksum = null
 Checksum of all the data in the block. This value serves as the basis for block signatures since no block contents may be changed without affecting the block checksum. More...
 
byte [] lastBlockChecksum = null
 Checksum of the previous block, so that accepting a new block indirectly confirms and validates all past blocks. This is the basic functionality of DLT. More...
 
byte [] walletStateChecksum = null
 Checksum of the WalletState after the transactions in this block are applied to the WalletState from the previous block. More...
 
byte [] signatureFreezeChecksum = null
 Checksum of the final list of signatures for block blockNum - 5. More...
 
long timestamp = 0
 Unix Epoch value of when the block was generated. More...
 
ulong difficulty = 0
 Ixian Hybrid PoW difficulty value. More...
 
Dictionary< ulong, SuperBlockSegmentsuperBlockSegments = new Dictionary<ulong, SuperBlockSegment>()
 List of blocks and their checksums - used only in the superblock functionality. More...
 
byte [] lastSuperBlockChecksum = null
 Checksum of the previous superblock - used only in superblock functinality. More...
 
ulong lastSuperBlockNum = 0
 Block height of the previous superblock - used only in superblock functionality. More...
 
byte [] powField = null
 Ixian Hybrid PoW solution, if it exists for this block. More...
 
bool fromLocalStorage = false
 Indicator which shows if the block was processed through the Consensus algorithm, or read from cold storage. More...
 
bool compacted = false
 Indicator to show if the block has already been compacted through the superblock functionality. More...
 
bool compactedSigs = false
 Indicator to show if the block's signatures have been compacted through the superblock functionality. More...
 

Static Public Attributes

static int maxVersion = 4
 Latest possible version of the Block structure. New blocks should usually be created with the latest version. More...
 

Properties

ulong blockNum [get, set]
 Block height (block number). This is a sequential index in the blockchain which uniquely identifies each block. More...
 
bool isGenesis [get]
 Test if the block is the genesis block. More...
 

Detailed Description

An Ixian DLT Block. A block contains all the transactions which act on the WalletState and various checksums which validate the actions performed on the blockchain. Blocks are the fundamental data structure of Distributed Ledger Technology (DLT) and form a chain of valid states from the so-called 'Genesis Block' to the present moment. An Ixian Block must include checksums of the previous block, checksums of the internal data structures (WalletState) and a list of transactions which have updated the WalletState from its previous value to its current value. In addition, a block contains cryptographic signatures of Master nodes, which is the basis for the Ixian Consensus algorithm.

Definition at line 32 of file Block.cs.

Constructor & Destructor Documentation

◆ Block() [1/3]

DLT.Block.Block ( )

Definition at line 155 of file Block.cs.

◆ Block() [2/3]

DLT.Block.Block ( Block  block)

Copies the given block rather than making a reference to it.

This constructor is used in some places of the DLT software where copies of the block data are required and where such a copy would improve performance by requiring less thread synchronziation.

Parameters
blockSource block.

Definition at line 170 of file Block.cs.

◆ Block() [3/3]

DLT.Block.Block ( byte []  bytes)

Reconstructs a Block from the bytestream. See also getBytes.

Each block has a getBytes() function which serializes the block data into a byte buffer, suitable for sending over the network. This constructor can re-create the block from the given bytestream.

Parameters
bytesBlock bytes, usually received from the network.

Definition at line 255 of file Block.cs.

Member Function Documentation

◆ addSignature()

bool DLT.Block.addSignature ( byte []  signature,
byte []  address_or_pub_key 
)

Adds the provided signature to the block's signature list.

Parameters
signatureByte value of the signature.
address_or_pub_keyAddress or public key of the signer.
Returns
True, if the signature was successfully added. False is returned if the signature was already present, or was not valid.

Definition at line 794 of file Block.cs.

◆ addSignaturesFrom()

List<byte[][]> DLT.Block.addSignaturesFrom ( Block  other)

Mergest the signatures of two blocks without duplicating.

This is used when the Master Node has been working on one set of signatures but receives the same block with a different set of signatures and wishes to merge the two lists together. The function returns the list signatures which were in the other block, but not in this, while at the same time adding the new signatures to this block.

Parameters
otherThe other block (should be the same blockNum) whose signatures will be merged.
Returns
The list of 'new' signatures.

Definition at line 743 of file Block.cs.

◆ addTransaction()

bool DLT.Block.addTransaction ( string  txid)

Adds an Ixian Transaction to the block. The transaction must already be present in the TransactionPool.

Note that the transaction is not executed against the WalletState when it's added to the block with this function. It is the responsibiltiy of the Master Node implementation to ensure that all transactions, which are added to a specific block, are also applied against the WalletState, so that the walletStateSchecksum represents the finishing state.

Parameters
txidID of the transaction to add.
Returns
True, if the transaction was added successfully.

Definition at line 515 of file Block.cs.

◆ applySignature()

byte [][] DLT.Block.applySignature ( )

Signs the Block with the running DLT Master Node's private key.

Signing the block indicates that the node has executed all transactions, specified in this block and has confirmed that the resulting state of all wallets (WalletState) matches the one in the walletStateChecksum field. The starting point for the transactions is the Wallet State from the previous block. The resulting signature may include either the node's public key, or its signing address, depending if the public key can be obtained through other means. An example of this is when this node's public key is present in the Presence List.

Returns
Byte array with the node's signature and public key or address.

Definition at line 661 of file Block.cs.

◆ calculateChecksum()

byte [] DLT.Block.calculateChecksum ( )

Calculates the blockChecksum of the DLT Block, using the relevant fields.

Returns
Byte value of the checksum result.

Definition at line 539 of file Block.cs.

◆ calculateSignatureChecksum()

byte [] DLT.Block.calculateSignatureChecksum ( )

Calculates the checksum of all signatures on this block.

This is used for the signature freeze functionality of the Ixian DLT. See remarks on the signatureFreezeChecksum field for details.

Returns
Byte value of the signature checksum.

Definition at line 607 of file Block.cs.

◆ compact()

bool DLT.Block.compact ( )

Removes the signatures as part of the compaction process (superblock functionality).

Returns
True if compaction was performed, false if the block is already compacted.

Definition at line 1154 of file Block.cs.

◆ containsSignature()

bool DLT.Block.containsSignature ( byte []  address_or_pub_key)

Checks if the block's signatures field contains the signature of the specified node. Either the node's address or its public key is accepted.

Parameters
address_or_pub_keyThe signer's address or public key.
Returns

Definition at line 704 of file Block.cs.

◆ Equals()

bool DLT.Block.Equals ( Block  b)

Implementation of block equality.

Due to how a distributed ledger works as a technology, the comparison must only examine certain checksums of both blocks to verify whether they are equal or not.

Parameters
bOther block, sometimes called the RHS (Right-hand-side)
Returns
True if the blocks are equal.

Definition at line 480 of file Block.cs.

◆ getBytes()

byte [] DLT.Block.getBytes ( )

Retrieves the block in its serialized, 'byte stream' format. See also Block(byte[] bytes).

A block can be serialized for network transmission using this function. All relevant fields will be encoded and a byte buffer will be returned. The byte buffer contains a copy of the block, so no thread synchronization is required.

Returns
Byte buffer with the serialized block.

Definition at line 365 of file Block.cs.

◆ getSignatureCount()

int DLT.Block.getSignatureCount ( )

Retrives the number of signatures on this block. This function might return a larger value, because it does not check for potential duplicates.

Returns
Number of signatures.

Definition at line 1044 of file Block.cs.

◆ getSignaturesWalletAddresses()

List<byte[]> DLT.Block.getSignaturesWalletAddresses ( bool  convert_pubkeys = true)

Retrieves a list of Ixian Wallet addresses from the list of signatures on this block.

Since signatures on the block may include either an address or a public key, this function performs the necessary lookups to return only the Wallet addresses of all signers. If the parameter convert_pubkeys is specified false, then the public key lookups aren't performed and only the addresses from the signature list are returned.

Parameters
convert_pubkeysTrue if public key signatures should be converted back to their respective Ixian Wallet addresses.
Returns
List of Ixian wallets which have signed this block.

Definition at line 983 of file Block.cs.

◆ getSignerPubKey()

byte [] DLT.Block.getSignerPubKey ( byte []  address_or_pub_key)

Attempts to retrieve the public key of the signer address.

This function accepts either a wallet address or a public key. In the latter case, the public key is returned directly, but in the former case, the public key is looked up from the wallet. This allows easy conversion from the signatures field for use in the verify function.

Parameters
address_or_pub_keySigner address or public key.
Returns
Public key, matching the given address, or null, if the public key is not known.

Definition at line 825 of file Block.cs.

◆ getUniqueSignatureCount()

int DLT.Block.getUniqueSignatureCount ( )

Retrieves the number of unique signatures on the block. Signatures are verified so that only unique ones are included.

Returns
Number of unique signatures.

Definition at line 1060 of file Block.cs.

◆ hasNodeSignature()

bool DLT.Block.hasNodeSignature ( byte []  public_key = null)

Checks the signatures on the block and returns true, if the block has already been signed by the given public key.

Parameters
public_keyThe public key to check.
Returns
True, if the public key has already signed the block.

Definition at line 914 of file Block.cs.

◆ logBlockDetails()

void DLT.Block.logBlockDetails ( )

Writes the block's details to the log for debugging purposes.

Definition at line 1176 of file Block.cs.

◆ pruneSignatures()

bool DLT.Block.pruneSignatures ( )

?

Returns

Definition at line 1115 of file Block.cs.

◆ setWalletStateChecksum()

void DLT.Block.setWalletStateChecksum ( byte []  checksum)

Allocates and sets the walletStateChecksum.

Parameters
checksumChecksum byte value.

Definition at line 1105 of file Block.cs.

◆ verifySignature()

bool DLT.Block.verifySignature ( byte []  signature,
byte []  signer_pub_key 
)

Verifies if the given signature is valid for this block.

Please note that this function only accepts a public key. If the signature is supplied with an address, the public key must somehow be obtained prior to calling this function, either by taking it from the Presence List, or querying the network.

Parameters
signatureSignature's byte value.
signer_pub_keyPublic key of the signer.
Returns
True, if the signature validates this block.

Definition at line 783 of file Block.cs.

◆ verifySignatures()

bool DLT.Block.verifySignatures ( bool  skip_sig_verification = false)

Verifies that all signatures on this block are valid.

Checks if all the given signatures and signer addresses match and are valid. In the simpler form (skip_sig_verification), this function only checks that public keys for all signatures exist and that all signers are known, without cryptographically verifying that each signature matches the block.

Parameters
skip_sig_verificationFalse for simpler, non-cryptographic verification.
Returns
True if all signatures are valid and (optionally) match the block's checksum.

Definition at line 854 of file Block.cs.

Member Data Documentation

◆ blockChecksum

byte [] DLT.Block.blockChecksum = null

Checksum of all the data in the block. This value serves as the basis for block signatures since no block contents may be changed without affecting the block checksum.

Definition at line 70 of file Block.cs.

◆ compacted

bool DLT.Block.compacted = false

Indicator to show if the block has already been compacted through the superblock functionality.

Definition at line 137 of file Block.cs.

◆ compactedSigs

bool DLT.Block.compactedSigs = false

Indicator to show if the block's signatures have been compacted through the superblock functionality.

Definition at line 141 of file Block.cs.

◆ difficulty

ulong DLT.Block.difficulty = 0

Ixian Hybrid PoW difficulty value.

Ixian Blockchain works on a consensus model and mining is not strictly required. An optional mining system is included to enable initial coin supply distribution. The mining algorithm is Argon2id and the solutions are not included in blocks themselves. There is a special Transaction type which submits a solution to a block. Miners are able to work on any block in the Redacted History window, with the target block specifying its difficulty to which the posted solution must conform.

Definition at line 105 of file Block.cs.

◆ fromLocalStorage

bool DLT.Block.fromLocalStorage = false

Indicator which shows if the block was processed through the Consensus algorithm, or read from cold storage.

Definition at line 132 of file Block.cs.

◆ lastBlockChecksum

byte [] DLT.Block.lastBlockChecksum = null

Checksum of the previous block, so that accepting a new block indirectly confirms and validates all past blocks. This is the basic functionality of DLT.

Definition at line 74 of file Block.cs.

◆ lastSuperBlockChecksum

byte [] DLT.Block.lastSuperBlockChecksum = null

Checksum of the previous superblock - used only in superblock functinality.

Definition at line 113 of file Block.cs.

◆ lastSuperBlockNum

ulong DLT.Block.lastSuperBlockNum = 0

Block height of the previous superblock - used only in superblock functionality.

Definition at line 117 of file Block.cs.

◆ maxVersion

int DLT.Block.maxVersion = 4
static

Latest possible version of the Block structure. New blocks should usually be created with the latest version.

Definition at line 37 of file Block.cs.

◆ powField

byte [] DLT.Block.powField = null

Ixian Hybrid PoW solution, if it exists for this block.

This field is not included in the block checksum, nor is it transmitted over the network. Master Nodes fill this information for themselves from the special PoW-Solution transaction types in the TransactionPool.

Definition at line 126 of file Block.cs.

◆ signatureFreezeChecksum

byte [] DLT.Block.signatureFreezeChecksum = null

Checksum of the final list of signatures for block blockNum - 5.

In this way, the signers list is 'frozen' and may no longer be changed, preventing various possible tampering attacks. Since the payout of many of the Ixian DLT's Master Node functions is tied to the accepted signature list, this field protects that list from malicious tinkering. Changes are permitted for five blocks to allow slower nodes to process and apply their signatures.

Definition at line 92 of file Block.cs.

◆ signatures

List<byte[][]> DLT.Block.signatures = new List<byte[][]> { }

The list of Master Node signatures which enable the Ixian Consensus algorithm.

Definition at line 52 of file Block.cs.

◆ superBlockSegments

Dictionary<ulong, SuperBlockSegment> DLT.Block.superBlockSegments = new Dictionary<ulong, SuperBlockSegment>()

List of blocks and their checksums - used only in the superblock functionality.

Definition at line 109 of file Block.cs.

◆ timestamp

long DLT.Block.timestamp = 0

Unix Epoch value of when the block was generated.

Definition at line 96 of file Block.cs.

◆ transactions

List<string> DLT.Block.transactions = new List<string> { }

The list of transactions which should act on the WalletState from the previous block to produce the WalletState for this block.

Definition at line 47 of file Block.cs.

◆ version

int DLT.Block.version = 0

Block version.

New blocks should always be generated with the latest version - maxVersion, except during the transitional period while the network is upgrading from one block version to the next. Older blocks, retrieved from files or the network may have an older version and this field identifies which version the specific block has. Some Block features are only enabled from specific versions forward.

Definition at line 65 of file Block.cs.

◆ walletStateChecksum

byte [] DLT.Block.walletStateChecksum = null

Checksum of the WalletState after the transactions in this block are applied to the WalletState from the previous block.

This allows Ixian Master Nodes to operate on the WalletState and be certain that it matches all other Master nodes without exchanging all the wallet data. WalletState is synchornized when the node first boots up, but is never transferred between nodes later, since it can be updated in a consistent manner using the transactions and wallet state checksums in each block.

Definition at line 83 of file Block.cs.

Property Documentation

◆ blockNum

ulong DLT.Block.blockNum
getset

Block height (block number). This is a sequential index in the blockchain which uniquely identifies each block.

Definition at line 42 of file Block.cs.

◆ isGenesis

bool DLT.Block.isGenesis
get

Test if the block is the genesis block.

Definition at line 1201 of file Block.cs.


The documentation for this class was generated from the following file: