Unit Noso.Gvt

Description

Unit for managing a GVT (Governance Token)

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Packed Record TGovernanceToken Record representing a Governance Token (GVT)

Functions and Procedures

function CalculateGVTPrice(Available: Integer; ForSale: Boolean = False): Int64;
function ChangeGVTOwner(Number: Integer; OldOwner, NewOwner: String): Integer;
function CountAvailableGVTs(): Integer;
function CreateGVTFile(): Boolean;
function GetGVTAsStream(out Stream: TMemoryStream): Int64;
function GetGVTByIndex(Index: Integer): TGovernanceToken;
function GetGVTCount: Integer;
procedure LoadGVTsFileData();
procedure SaveGVTsAsData();
function SaveStreamAsGVTs(Stream: TMemoryStream): Boolean;

Constants

GVTBaseValue = 70000000000;

Variables

GVTArray: array of TGovernanceToken;
GVTArrayLock: TRTLCriticalSection;
GVTFile: file of TGovernanceToken;
GVTFileLock: TRTLCriticalSection;
GVTFilename: String = 'NOSODATA' + DirectorySeparator + 'gvts.psk';
GVTHashMD5: String = '';

Description

Functions and Procedures

function CalculateGVTPrice(Available: Integer; ForSale: Boolean = False): Int64;

Calculates the price of a Governance Token based on the number of available GVTs.

Parameters
Available
The number of GVTs available.
ForSale
Whether the price is for selling (True) or buying (False).
Returns

The calculated price of the GVT.

function ChangeGVTOwner(Number: Integer; OldOwner, NewOwner: String): Integer;

( Changes the owner of a Governance Token given its number. (

Parameters
Number
The number of the GVT to change.
OldOwner
The current owner's address.
NewOwner
The new owner's address.
Returns

0 for success, or an error code (1, 2, 3).

function CountAvailableGVTs(): Integer;

Counts the number of available Governance Tokens (GVTs belonging to the development fund).

Returns

The count of available GVTs.

function CreateGVTFile(): Boolean;

Creates an empty GVT file. If a file already exists, it is overwritten with an empty one.

Returns

True if the file was successfully created; False otherwise.

function GetGVTAsStream(out Stream: TMemoryStream): Int64;

Loads the GVT file into a memory stream.

Parameters
Stream
The memory stream to load the GVT file into.
Returns

Size of the loaded stream in bytes.

function GetGVTByIndex(Index: Integer): TGovernanceToken;

Retrieves a Governance Token record by its index in the array.

.

Parameters
Index
The index of the GVT to retrieve.
Returns

The requested GVT record.

function GetGVTCount: Integer;

Returns the number of Governance Token records currently loaded in the array.

Returns

The number of GVT records.

procedure LoadGVTsFileData();

Loads the GVT file data into an array. The array holds all GVT records from the file.

procedure SaveGVTsAsData();

Saves the GVT array data back to the file.

function SaveStreamAsGVTs(Stream: TMemoryStream): Boolean;

Saves the provided memory stream as the GVT file.

Parameters
Stream
The memory stream to save.
Returns

True if the file was successfully saved; False otherwise.

Constants

GVTBaseValue = 70000000000;

Base value of a Governance Token

Variables

GVTArray: array of TGovernanceToken;

Array to hold loaded GVT records

GVTArrayLock: TRTLCriticalSection;

Critical section for synchronizing array access

GVTFile: file of TGovernanceToken;

File variable for GVT file handling

GVTFileLock: TRTLCriticalSection;

Critical section for synchronizing file access

GVTFilename: String = 'NOSODATA' + DirectorySeparator + 'gvts.psk';

Filename for GVT storage

GVTHashMD5: String = '';

MD5 hash of the Governance Token file


Generated by PasDoc 0.16.0-snapshot.