Unit Noso.Consensus

Description

Noso Unit to get a consensus

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TAutoConsensusThread This thread automatically computes consensus at regular intervals based on block age and timestamp.
Record TConsensusData Record to store consensus values and their occurrence count.
Record TNodeConsensus Record type to store information about a node in the network.
Class TNodeStatusThread This class represents a thread that communicates with a specific node to obtain its status.

Functions and Procedures

function ComputeConsensus(NodeList: String = ''): TConsensus;
function GetActiveThreadCount(): Integer;
function GetConsensusData(Index: Integer = 0): String;
function GetConsensusHash(Line: String): String;
function GetNodeCount(): Integer;
function GetNodeDataByIndex(Index: Integer): TNodeConsensus;
function GetRandomNode(): String;
procedure SetNodeList(NodeListString: String);
procedure StartAutoConsensus();
procedure StopAutoConsensus();

Types

TConsensus = array of String[32];

Constants

cCFGHash = 19;
cGVTsHash = 18;
cHeaders = 5;
cLastBlock = 2;
cLBHash = 10;
cLBTimeEnd = 12;
cMNsCount = 9;
cMNsHash = 8;
cSumHash = 17;

Variables

ConsensusCompleted: Boolean = False;
ConsensusLabels: array[0..20] of String = ('Resume', 'Peers', 'LBlock', 'Pending', 'Delta', 'Headers', 'Version', 'UTCTime', 'MNsHash', 'MNsCount', 'LBHash', 'BestDiff', 'LBTimeEnd', 'LBMiner', 'ChecksCount', 'LBPoW', 'LBDiff', 'Summary', 'GVTs', 'NosoCFG', 'PSOHash');
ConsensusPercentage: Integer = 0;
ConsensusResults: TConsensus;
LastConsensusTimestamp: Int64 = 0;
ReachedNodes: Integer = 0;
TotalNodes: Integer = 0;
ValidNodes: Integer = 0;

Description

Functions and Procedures

function ComputeConsensus(NodeList: String = ''): TConsensus;

Compute consensus data from the node list.

Parameters
NodeList
Optional node list as a string.
Returns

Array of consensus results.

function GetActiveThreadCount(): Integer;

Returns the number of active threads.

Returns

the number of active threads.

function GetConsensusData(Index: Integer = 0): String;

Returns the consensus result for the given index.

Parameters
Index
The index of the consensus data.
Returns

A string representing the consensus value.

function GetConsensusHash(Line: String): String;

Computes a consensus hash based on the given status line.

Parameters
Line
The status line received from the node.
Returns

A string representing the computed hash.

function GetNodeCount(): Integer;

Returns the number of nodes in the node list.

function GetNodeDataByIndex(Index: Integer): TNodeConsensus;

Returns the node data for the given index.

Parameters
Index
The index of the node.
Returns

The consensus data for the specified node.

function GetRandomNode(): String;

Returns a randomly selected node from the node list as a string.

procedure SetNodeList(NodeListString: String);

Sets the node list based on the input string.

Parameters
NodeListString
The node list as a string.
procedure StartAutoConsensus();

Starts the automatic consensus thread.

procedure StopAutoConsensus();

Stops the automatic consensus thread.

Types

TConsensus = array of String[32];

Array that stores consensus results.

Constants

cCFGHash = 19;

The index for Noso configuration hash in consensus results

cGVTsHash = 18;

The index for GVTs hash in consensus results

cHeaders = 5;

The index for headers in consensus results

cLastBlock = 2;

The index for last block in consensus results

cLBHash = 10;

The index for last block hash in consensus results

cLBTimeEnd = 12;

The index for last block time end in consensus results

cMNsCount = 9;

The index for MNs count in consensus results

cMNsHash = 8;

The index for MNs hash in consensus results

cSumHash = 17;

The index for summary hash in consensus results

Variables

ConsensusCompleted: Boolean = False;

Whether consensus is completed

ConsensusLabels: array[0..20] of String = ('Resume', 'Peers', 'LBlock', 'Pending', 'Delta', 'Headers', 'Version', 'UTCTime', 'MNsHash', 'MNsCount', 'LBHash', 'BestDiff', 'LBTimeEnd', 'LBMiner', 'ChecksCount', 'LBPoW', 'LBDiff', 'Summary', 'GVTs', 'NosoCFG', 'PSOHash');

Stores the consensus labels

ConsensusPercentage: Integer = 0;

Percentage of nodes reached

ConsensusResults: TConsensus;

Stores the computed consensus results

LastConsensusTimestamp: Int64 = 0;

Timestamp of last consensus

ReachedNodes: Integer = 0;

Nodes reached during consensus

TotalNodes: Integer = 0;

Total number of nodes

ValidNodes: Integer = 0;

Valid nodes in the consensus process


Generated by PasDoc 0.16.0-snapshot.