Unit Noso.Summary

Description

This item has no description.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TBlockRecord Holds information about a block, including its disk position and associated summary data.
Packed Record TOrderGroup Manages the details of an order within the system.
Packed Record TSummaryData Holds the data for each address' summary

Functions and Procedures

function ComputeSummaryHash: String;
procedure CreateNewSummaryFile(AddBlockZero: Boolean);
function CreateProtocolOrder(BlockNumber: Integer; OrderType, Sender, Receiver, Signature: String; TimeStamp, Amount: Int64): TOrderData;
function CreateSummaryBackup(): Boolean;
function CreateSummaryIndex(): Int64;
procedure CreditTo(Address: String; Amount, BlockNumber: Int64);
function FindSummaryIndexPosition(Text: String; out RecordData: TSummaryData; IsAlias: Boolean = False): Int64;
function GetAddressAlias(Address: String): String;
function GetAddressBalanceIndexed(Address: String): Int64;
function GetAddressLastOperation(Address: String): Int64;
function GetSummaryAsMemoryStream(out Stream: TMemoryStream): Int64;
function GetZipSummaryAsMemoryStream(out Stream: TMemoryStream): Int64;
function IsCustomizationValid(Address, Custom: String; BlockNumber: Int64; ForceCustom: Boolean = False): Boolean;
function IsSummaryValidPayment(Address: String; Amount, BlockNumber: Int64): Boolean;
procedure ProcessSummaryPayment(Address: String; Amount, BlockNumber: Int64);
procedure ResetBlockRecords();
function RestoreSummaryBackup(): Boolean;
function SaveSummaryToFile(Stream: TMemoryStream): Int64;
procedure SetSummaryHash();
function SummaryIndexLength(): Int64;
procedure UpdateSummaryChanges();
function ZipSummary(): Boolean;

Types

TIndexRecord = array of Integer;

Variables

SummaryFileName: String = 'NOSODATA' + DirectorySeparator + 'sumary.psk';
SummaryHashValue: String = '';
SummaryLastOperation: Int64;
WorkingDirectory: String = '';
ZipSummaryFileName: String = 'NOSODATA' + DirectorySeparator + 'sumary.zip';

Description

Functions and Procedures

function ComputeSummaryHash: String;

Retrieves the current hash value of the summary file.

Returns

The hash value as a string.

procedure CreateNewSummaryFile(AddBlockZero: Boolean);

Initializes a new summary file on disk.

Parameters
AddBlockZero
If True, a zero block is added to the summary file and updates the summary.
function CreateProtocolOrder(BlockNumber: Integer; OrderType, Sender, Receiver, Signature: String; TimeStamp, Amount: Int64): TOrderData;

Initializes a new order with the specified parameters.

Parameters
BlockNumber
The block number where the order is recorded.
OrderType
Type of order.
Sender
The address of the sender.
Receiver
The address of the receiver.
Signature
Digital signature of the order.
TimeStamp
Timestamp of when the order is created.
Amount
Amount related to the order.
Returns

A TOrderData structure containing the initialized order information.

function CreateSummaryBackup(): Boolean;

Creates a backup of the current summary file.

Returns

True if the backup operation is successful, otherwise False.

function CreateSummaryIndex(): Int64;

Creates the summary index from the disk summary file.

Returns

The time taken to create the summary index in milliseconds.

procedure CreditTo(Address: String; Amount, BlockNumber: Int64);

Credits a specified amount to a specific address, updating its balance.

Parameters
Address
The address to which the amount will be credited.
Amount
The amount to be credited.
BlockNumber
The block number in which the credit is applied.
function FindSummaryIndexPosition(Text: String; out RecordData: TSummaryData; IsAlias: Boolean = False): Int64;

Searches for a summary record in the index based on the provided text.

Parameters
Text
The text (hash or alias) to search for in the index.
RecordData
Output parameter that will hold the found record data.
IsAlias
If true, searches for a custom alias instead of the hash.
Returns

The index position of the found record, or -1 if not found.

function GetAddressAlias(Address: String): String;

Retrieves the custom alias for a specified address, if it exists.

Parameters
Address
The address to look up the alias for.
Returns

The custom alias associated with the address, or an empty string if none exists.

function GetAddressBalanceIndexed(Address: String): Int64;

Retrieves the balance of a specific address from the summary index.

Parameters
Address
The address whose balance is to be retrieved.
Returns

The balance of the specified address, or 0 if not found.

function GetAddressLastOperation(Address: String): Int64;

Retrieves the last operation block number associated with a specified address.

Returns the address last operation block

Parameters
Address
The address to look up.
Returns

The block number of the last operation, or 0 if not found.

function GetSummaryAsMemoryStream(out Stream: TMemoryStream): Int64;

Loads the summary file into a memory stream.

Parameters
Stream
The output memory stream that will contain the summary data.
Returns

The size of the summary data loaded into the stream.

function GetZipSummaryAsMemoryStream(out Stream: TMemoryStream): Int64;

Loads the zipped summary file into a memory stream.

Parameters
Stream
The output memory stream that will contain the zipped summary data.
Returns

The size of the zipped summary data loaded into the stream.

function IsCustomizationValid(Address, Custom: String; BlockNumber: Int64; ForceCustom: Boolean = False): Boolean;

Checks if an address can customize its alias based on current balance and conditions.

Parameters
Address
The address to verify customization for.
Custom
The new custom alias to be set.
BlockNumber
The block number in which the customization is processed.
ForceCustom
If true, bypasses balance checks for customization.
Returns

True if the customization is valid, otherwise False.

function IsSummaryValidPayment(Address: String; Amount, BlockNumber: Int64): Boolean;

Verifies if a sender address has enough funds for a specified payment amount.

Parameters
Address
The address of the sender.
Amount
The amount to be paid.
BlockNumber
The block number in which the payment is being processed.
Returns

True if the payment is valid, otherwise False.

procedure ProcessSummaryPayment(Address: String; Amount, BlockNumber: Int64);

Processes a payment for a specified address, updating its balance.

Parameters
Address
The address to process the payment for.
Amount
The amount to be deducted from the address's balance.
BlockNumber
The block number in which the payment is processed.
procedure ResetBlockRecords();

Resets the block records by clearing the block records array.

function RestoreSummaryBackup(): Boolean;

Restores the summary file from a backup.

Returns

True if the restore operation is successful, otherwise False.

function SaveSummaryToFile(Stream: TMemoryStream): Int64;

Saves the content of a memory stream to a specified file.

Parameters
Stream
The memory stream containing the data to save.
Returns

The size of the stream.

procedure SetSummaryHash();

Calculates and sets the hash value for the summary file.

function SummaryIndexLength(): Int64;

Returns the length of the summary index.

Returns

The length of the summary index.

procedure UpdateSummaryChanges();

Processes and writes changes made to the summary in memory to the disk.

function ZipSummary(): Boolean;

Compresses the current summary file into a ZIP archive.

Must be replaced with new stream compression methods

Returns

True if the zipping operation succeeds, otherwise False.

Types

TIndexRecord = array of Integer;

This item has no description.

Variables

SummaryFileName: String = 'NOSODATA' + DirectorySeparator + 'sumary.psk';

The file name for the summary data, located in the 'NOSODATA' directory.

SummaryHashValue: String = '';

The MD5 hash value of the summary file for integrity checks.

SummaryLastOperation: Int64;

Holds the block number of the last operation performed on the summary data.

WorkingDirectory: String = '';

The current working directory for the application.

ZipSummaryFileName: String = 'NOSODATA' + DirectorySeparator + 'sumary.zip';

The file name for the zipped summary data, located in the 'NOSODATA' directory.


Generated by PasDoc 0.16.0-snapshot.