sgns::Blockchain¶
#include <Blockchain.hpp>
Inherits from std::enable_shared_from_this< Blockchain >
Public Types¶
| Name | |
|---|---|
| enum class | Error { GENESIS_BLOCK_CREATION_FAILED = 0, GENESIS_BLOCK_INVALID_SIGNATURE, GENESIS_BLOCK_UNAUTHORIZED_CREATOR, GENESIS_BLOCK_SERIALIZATION_FAILED, GENESIS_BLOCK_MISSING, ACCOUNT_CREATION_BLOCK_MISSING, ACCOUNT_CREATION_BLOCK_CREATION_FAILED, ACCOUNT_CREATION_BLOCK_INVALID_SIGNATURE, ACCOUNT_CREATION_BLOCK_SERIALIZATION_FAILED, ACCOUNT_CREATION_BLOCK_INVALID_GENESIS_LINK, VALIDATOR_REGISTRY_CREATION_FAILED, BLOCKCHAIN_NOT_INITIALIZED} Error class of the Blockchain module. |
| using std::function< void(outcome::result< void >)> | BlockchainCallback |
Public Functions¶
| Name | |
|---|---|
| std::shared_ptr< Blockchain > | New(std::shared_ptr< crdt::GlobalDB > global_db, std::shared_ptr< GeniusAccount > account, BlockchainCallback callback) Factory method to create Blockchain as shared_ptr. |
| void | SetAuthorizedFullNodeAddress(const std::string & pub_address) Set the authorized full node public address (for testing purposes). |
| const std::string & | GetAuthorizedFullNodeAddress() Get the current authorized full node public address. |
| ~Blockchain() | |
| outcome::result< void > | Start() Start the blockchain with async genesis block handling. |
| outcome::result< void > | Stop() |
| outcome::result< void > | OnGenesisBlockReceived(const base::Buffer & serialized_genesis) Handle received genesis block from pubsub. |
| outcome::result< void > | OnAccountCreationBlockReceived(const base::Buffer & serialized_account_creation) Handle received account creation block from pubsub. |
| outcome::result< std::string > | GetGenesisCID() const |
| outcome::result< std::string > | GetAccountCreationCID() const |
| void | SetFullNodeMode() |
Protected Functions¶
| Name | |
|---|---|
| outcome::result< void > | MigrateCids(const std::shared_ptr< crdt::GlobalDB > & old_db, const std::shared_ptr< crdt::GlobalDB > & new_db) |
Friends¶
| Name | |
|---|---|
| class | Migration3_5_1To3_6_0 |
Public Types Documentation¶
enum Error¶
| Enumerator | Value | Description |
|---|---|---|
| GENESIS_BLOCK_CREATION_FAILED | 0 | Failed to create the genesis block. |
| GENESIS_BLOCK_INVALID_SIGNATURE | Genesis block has invalid signature. | |
| GENESIS_BLOCK_UNAUTHORIZED_CREATOR | Genesis block created by unauthorized key. | |
| GENESIS_BLOCK_SERIALIZATION_FAILED | Failed to serialize/deserialize genesis block. | |
| GENESIS_BLOCK_MISSING | Genesis block wasn't received. | |
| ACCOUNT_CREATION_BLOCK_MISSING | Account creation is missing. | |
| ACCOUNT_CREATION_BLOCK_CREATION_FAILED | Failed to create account creation block. | |
| ACCOUNT_CREATION_BLOCK_INVALID_SIGNATURE | Account creation block has invalid signature. | |
| ACCOUNT_CREATION_BLOCK_SERIALIZATION_FAILED | Failed to serialize/deserialize account creation block. | |
| ACCOUNT_CREATION_BLOCK_INVALID_GENESIS_LINK | Account creation block not properly linked to genesis. | |
| VALIDATOR_REGISTRY_CREATION_FAILED | Failed to create validator registry. | |
| BLOCKCHAIN_NOT_INITIALIZED | Blockchain not fully initialized yet. |
Error class of the Blockchain module.
using BlockchainCallback¶
Public Functions Documentation¶
function New¶
static std::shared_ptr< Blockchain > New(
std::shared_ptr< crdt::GlobalDB > global_db,
std::shared_ptr< GeniusAccount > account,
BlockchainCallback callback
)
Factory method to create Blockchain as shared_ptr.
Parameters:
- global_db CRDT database instance.
- account GeniusAccount instance.
- callback Called when initialization completes.
Return: shared_ptr to Blockchain instance.
function SetAuthorizedFullNodeAddress¶
Set the authorized full node public address (for testing purposes).
Parameters:
- pub_address The public address that is authorized to create genesis blocks
function GetAuthorizedFullNodeAddress¶
Get the current authorized full node public address.
Return: The authorized full node public address
function ~Blockchain¶
function Start¶
Start the blockchain with async genesis block handling.
function Stop¶
function OnGenesisBlockReceived¶
Handle received genesis block from pubsub.
Parameters:
- serialized_genesis The received genesis block data
function OnAccountCreationBlockReceived¶
outcome::result< void > OnAccountCreationBlockReceived(
const base::Buffer & serialized_account_creation
)
Handle received account creation block from pubsub.
Parameters:
- serialized_account_creation The received account creation block data
function GetGenesisCID¶
function GetAccountCreationCID¶
function SetFullNodeMode¶
Protected Functions Documentation¶
function MigrateCids¶
static outcome::result< void > MigrateCids(
const std::shared_ptr< crdt::GlobalDB > & old_db,
const std::shared_ptr< crdt::GlobalDB > & new_db
)
Friends¶
friend Migration3_5_1To3_6_0¶
Updated on 2026-03-04 at 13:10:43 -0800