Skip to content

sgns::GeniusNode

#include <GeniusNode.hpp>

Inherits from IComponent, std::enable_shared_from_this< GeniusNode >

Public Types

Name
enum class uint8_t NodeState
enum class uint8_t Error { INSUFFICIENT_FUNDS = 1, DATABASE_WRITE_ERROR = 2, INVALID_TRANSACTION_HASH = 3, INVALID_CHAIN_ID = 4, INVALID_TOKEN_ID = 5, TOKEN_ID_MISMATCH = 6, PROCESS_COST_ERROR = 7, PROCESS_INFO_MISSING = 8, INVALID_JSON = 9, INVALID_BLOCK_PARAMETERS = 10, NO_PROCESSOR = 11, NO_PRICE = 12, TRANSACTIONS_NOT_READY = 13}
GeniusNodeError class.

Public Functions

Name
std::shared_ptr< GeniusNode > New(const DevConfig_st & dev_config, bool autodht =true, bool isprocessor =true, uint16_t base_port =40001, bool is_full_node =false, bool use_upnp =true)
std::shared_ptr< GeniusNode > New(const DevConfig_st & dev_config, const char * eth_private_key, bool autodht =true, bool isprocessor =true, uint16_t base_port =40001, bool is_full_node =false, bool use_upnp =true)
std::shared_ptr< GeniusNode > New(const DevConfig_st & dev_config, const GeniusAccount::Credentials & credentials, bool autodht =true, bool isprocessor =true, uint16_t base_port =40001, bool is_full_node =false, bool use_upnp =true)
~GeniusNode() override
outcome::result< std::string > ProcessImage(const std::string & jsondata)
uint64_t GetProcessCost(std::shared_ptr< sgns::sgprocessing::ProcessingManager > & procmgr)
outcome::result< double > GetGNUSPrice()
virtual std::string GetName() override
std::string GetVersion()
outcome::result< std::pair< std::string, uint64_t > > MintTokens(uint64_t amount, const std::string & transaction_hash, const std::string & chainid, TokenID tokenid, std::chrono::milliseconds timeout =std::chrono::milliseconds(TIMEOUT_MINT))
Mints tokens by converting a string amount to fixed-point representation.
void AddPeer(const std::string & peer)
void RefreshUPNP(uint16_t pubsubport)
uint64_t GetBalance()
uint64_t GetBalance(TokenID token_id)
uint64_t GetBalance(const std::string & address)
uint64_t GetBalance(TokenID token_id, const std::string & address)
const std::vector< std::vector< uint8_t > > GetInTransactions() const
const std::vector< std::vector< uint8_t > > GetOutTransactions() const
std::string GetAddress() const
TokenID GetTokenID() const
processing::ProcessingServiceImpl::ProcessingStatus GetProcessingStatus() const
outcome::result< std::pair< std::string, uint64_t > > TransferFunds(uint64_t amount, const std::string & destination, TokenID token_id, std::chrono::milliseconds timeout)
outcome::result< std::string > TransferFunds(uint64_t amount, const std::string & destination, TokenID token_id)
outcome::result< std::pair< std::string, uint64_t > > PayDev(uint64_t amount, TokenID token_id, std::chrono::milliseconds timeout =std::chrono::milliseconds(TIMEOUT_TRANSFER))
std::shared_ptr< ipfs_pubsub::GossipPubSub > GetPubSub()
outcome::result< std::string > FormatTokens(uint64_t amount, const TokenID tokenId)
Formats a fixed-point amount into a human-readable string.
outcome::result< uint64_t > ParseTokens(const std::string & str, const TokenID tokenId)
Parses a human-readable string into a fixed-point amount.
void PrintDataStore() const
void StopProcessing()
void StartProcessing()
outcome::result< std::map< std::string, double > > GetCoinprice(const std::vector< std::string > & tokenIds)
outcome::result< std::map< std::string, std::map< int64_t, double > > > GetCoinPriceByDate(const std::vector< std::string > & tokenIds, const std::vector< int64_t > & timestamps)
outcome::result< std::map< std::string, std::map< int64_t, double > > > GetCoinPricesByDateRange(const std::vector< std::string > & tokenIds, int64_t from, int64_t to)
TransactionManager::TransactionStatus WaitForTransactionIncoming(const std::string & txId, std::chrono::milliseconds timeout)
TransactionManager::TransactionStatus WaitForTransactionOutgoing(const std::string & txId, std::chrono::milliseconds timeout)
TransactionManager::TransactionStatus WaitForEscrowRelease(const std::string & originalEscrowId, std::chrono::milliseconds timeout)
TransactionManager::State GetTransactionManagerState() const
TransactionManager::TransactionStatus GetTransactionStatus(const std::string & txId) const
void SetAuthorizedFullNodeAddress(const std::string & pub_address)
Set the authorized full node address for blockchain genesis verification.
const std::string & GetAuthorizedFullNodeAddress() const
Get the current authorized full node public address.
NodeState GetState() const

Protected Functions

Name
void SendTransactionAndProof(std::shared_ptr< IGeniusTransactions > tx, std::vector< uint8_t > proof)
void ConfigureTransactionFilterTimeoutsMs(uint64_t timeframe_limit_ms, uint64_t mutability_window_ms)

Public Attributes

Name
uint64_t TIMEOUT_ESCROW_PAY
uint64_t TIMEOUT_TRANSFER
uint64_t TIMEOUT_MINT

Protected Attributes

Name
std::string write_base_path_
std::shared_ptr< GeniusAccount > account_
UTXOManager utxo_manager_

Friends

Name
class TransactionSyncTest

Additional inherited members

Public Functions inherited from IComponent

Name
virtual ~IComponent() =default

Public Types Documentation

enum NodeState

Enumerator Value Description
CREATING 0
MIGRATING_DATABASE
INITIALIZING_DATABASE
INITIALIZING_PROCESSING
INITIALIZING_BLOCKCHAIN
INITIALIZING_TRANSACTIONS
INITIALIZING_DHT
READY

enum Error

Enumerator Value Description
INSUFFICIENT_FUNDS 1 Insufficient funds for a transaction.
DATABASE_WRITE_ERROR 2 Error writing data into the database.
INVALID_TRANSACTION_HASH 3 Input transaction hash is invalid.
INVALID_CHAIN_ID 4 Chain ID is invalid.
INVALID_TOKEN_ID 5 Token ID is invalid.
TOKEN_ID_MISMATCH 6 Informed Token ID doesn't match initialized ID.
PROCESS_COST_ERROR 7 The calculated Processing cost was negative.
PROCESS_INFO_MISSING 8 Processing information missing on JSON file.
INVALID_JSON 9 JSON cannot be parsed>.
INVALID_BLOCK_PARAMETERS 10 JSON params for blocks incorrect or missing>.
NO_PROCESSOR 11 No processor for this type.
NO_PRICE 12 Couldn't get price of gnus.
TRANSACTIONS_NOT_READY 13 Transactions aren't ready.

GeniusNodeError class.

Public Functions Documentation

function New

static std::shared_ptr< GeniusNode > New(
    const DevConfig_st & dev_config,
    bool autodht =true,
    bool isprocessor =true,
    uint16_t base_port =40001,
    bool is_full_node =false,
    bool use_upnp =true
)

function New

static std::shared_ptr< GeniusNode > New(
    const DevConfig_st & dev_config,
    const char * eth_private_key,
    bool autodht =true,
    bool isprocessor =true,
    uint16_t base_port =40001,
    bool is_full_node =false,
    bool use_upnp =true
)

function New

static std::shared_ptr< GeniusNode > New(
    const DevConfig_st & dev_config,
    const GeniusAccount::Credentials & credentials,
    bool autodht =true,
    bool isprocessor =true,
    uint16_t base_port =40001,
    bool is_full_node =false,
    bool use_upnp =true
)

function ~GeniusNode

~GeniusNode() override

function ProcessImage

outcome::result< std::string > ProcessImage(
    const std::string & jsondata
)

function GetProcessCost

uint64_t GetProcessCost(
    std::shared_ptr< sgns::sgprocessing::ProcessingManager > & procmgr
)

function GetGNUSPrice

outcome::result< double > GetGNUSPrice()

function GetName

inline virtual std::string GetName() override

Reimplements: IComponent::GetName

function GetVersion

std::string GetVersion()

function MintTokens

outcome::result< std::pair< std::string, uint64_t > > MintTokens(
    uint64_t amount,
    const std::string & transaction_hash,
    const std::string & chainid,
    TokenID tokenid,
    std::chrono::milliseconds timeout =std::chrono::milliseconds(TIMEOUT_MINT)
)

Mints tokens by converting a string amount to fixed-point representation.

Parameters:

  • amount Numeric value with amount in Minion Tokens (1e-6 GNUS Token)
  • transaction_hash Transaction hash on the source chain.
  • chainid Source chain identifier.
  • tokenid Token identifier to mint.
  • timeout Timeout for the mint operation.

Return: Outcome of mint token operation

function AddPeer

void AddPeer(
    const std::string & peer
)

function RefreshUPNP

void RefreshUPNP(
    uint16_t pubsubport
)

function GetBalance

uint64_t GetBalance()

function GetBalance

uint64_t GetBalance(
    TokenID token_id
)

function GetBalance

uint64_t GetBalance(
    const std::string & address
)

function GetBalance

uint64_t GetBalance(
    TokenID token_id,
    const std::string & address
)

function GetInTransactions

inline const std::vector< std::vector< uint8_t > > GetInTransactions() const

function GetOutTransactions

inline const std::vector< std::vector< uint8_t > > GetOutTransactions() const

function GetAddress

inline std::string GetAddress() const

function GetTokenID

inline TokenID GetTokenID() const

function GetProcessingStatus

inline processing::ProcessingServiceImpl::ProcessingStatus GetProcessingStatus() const

function TransferFunds

outcome::result< std::pair< std::string, uint64_t > > TransferFunds(
    uint64_t amount,
    const std::string & destination,
    TokenID token_id,
    std::chrono::milliseconds timeout
)

function TransferFunds

outcome::result< std::string > TransferFunds(
    uint64_t amount,
    const std::string & destination,
    TokenID token_id
)

function PayDev

outcome::result< std::pair< std::string, uint64_t > > PayDev(
    uint64_t amount,
    TokenID token_id,
    std::chrono::milliseconds timeout =std::chrono::milliseconds(TIMEOUT_TRANSFER)
)

function GetPubSub

inline std::shared_ptr< ipfs_pubsub::GossipPubSub > GetPubSub()

function FormatTokens

outcome::result< std::string > FormatTokens(
    uint64_t amount,
    const TokenID tokenId
)

Formats a fixed-point amount into a human-readable string.

Parameters:

  • amount Amount in Minion Tokens (1e-6 GNUS).
  • tokenId Optional token identifier: – empty: default (minion to GNUS) formatting – matches DevConfig.TokenID: child-token formatting – otherwise: returns Error::TOKEN_ID_MISMATCH

Return: Outcome result with the formatted string in GNUS or an error.

function ParseTokens

outcome::result< uint64_t > ParseTokens(
    const std::string & str,
    const TokenID tokenId
)

Parses a human-readable string into a fixed-point amount.

Parameters:

  • str String representation of an amount in GNUS.
  • tokenId Optional token identifier: – empty: default (GNUS to minion) parsing – matches DevConfig.TokenID: child-token parsing – otherwise: returns Error::TOKEN_ID_MISMATCH

Return: Outcome result with the parsed amount in Minion Tokens (1e-6 GNUS) or an error.

function PrintDataStore

void PrintDataStore() const

function StopProcessing

void StopProcessing()

function StartProcessing

void StartProcessing()

function GetCoinprice

outcome::result< std::map< std::string, double > > GetCoinprice(
    const std::vector< std::string > & tokenIds
)

function GetCoinPriceByDate

outcome::result< std::map< std::string, std::map< int64_t, double > > > GetCoinPriceByDate(
    const std::vector< std::string > & tokenIds,
    const std::vector< int64_t > & timestamps
)

function GetCoinPricesByDateRange

outcome::result< std::map< std::string, std::map< int64_t, double > > > GetCoinPricesByDateRange(
    const std::vector< std::string > & tokenIds,
    int64_t from,
    int64_t to
)

function WaitForTransactionIncoming

TransactionManager::TransactionStatus WaitForTransactionIncoming(
    const std::string & txId,
    std::chrono::milliseconds timeout
)

function WaitForTransactionOutgoing

TransactionManager::TransactionStatus WaitForTransactionOutgoing(
    const std::string & txId,
    std::chrono::milliseconds timeout
)

function WaitForEscrowRelease

TransactionManager::TransactionStatus WaitForEscrowRelease(
    const std::string & originalEscrowId,
    std::chrono::milliseconds timeout
)

function GetTransactionManagerState

TransactionManager::State GetTransactionManagerState() const

function GetTransactionStatus

TransactionManager::TransactionStatus GetTransactionStatus(
    const std::string & txId
) const

function SetAuthorizedFullNodeAddress

void SetAuthorizedFullNodeAddress(
    const std::string & pub_address
)

Set the authorized full node address for blockchain genesis verification.

Parameters:

  • pub_address The public address that is authorized to create genesis blocks

function GetAuthorizedFullNodeAddress

const std::string & GetAuthorizedFullNodeAddress() const

Get the current authorized full node public address.

Return: The authorized full node public address

function GetState

inline NodeState GetState() const

Protected Functions Documentation

function SendTransactionAndProof

void SendTransactionAndProof(
    std::shared_ptr< IGeniusTransactions > tx,
    std::vector< uint8_t > proof
)

function ConfigureTransactionFilterTimeoutsMs

void ConfigureTransactionFilterTimeoutsMs(
    uint64_t timeframe_limit_ms,
    uint64_t mutability_window_ms
)

Public Attributes Documentation

variable TIMEOUT_ESCROW_PAY

static uint64_t TIMEOUT_ESCROW_PAY = 30000;

variable TIMEOUT_TRANSFER

static uint64_t TIMEOUT_TRANSFER = 30000;

variable TIMEOUT_MINT

static uint64_t TIMEOUT_MINT = 30000;

Protected Attributes Documentation

variable write_base_path_

std::string write_base_path_;

variable account_

std::shared_ptr< GeniusAccount > account_;

variable utxo_manager_

UTXOManager utxo_manager_;

Friends

friend TransactionSyncTest

friend class TransactionSyncTest(
    TransactionSyncTest 
);

Updated on 2026-03-04 at 13:10:43 -0800