Skip to content

sgns::trustedpeer::TrustedPeerRegistry

Genesis-seeded, in-memory-cached, quorum-updatable trusted-peer set. Delegates ALL signature/quorum logic to SecureCrdt / SecureCrdtRegistry – no bespoke signature/quorum logic exists here (TPR-03).

#include <TrustedPeerRegistry.hpp>

Inherits from std::enable_shared_from_this< TrustedPeerRegistry >

Public Functions

Name
TrustedPeerRegistry(std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt, std::vector< std::string > genesis_peers, std::string bootstrapper_address, uint64_t quorum_threshold, sgns::crdt::HierarchicalKey base_key)
Constructs a TrustedPeerRegistry. The genesis peer list is cached immediately (D-05) –GetCurrentPeers() reflects it even before SeedGenesis/TryConfirm are called.
~TrustedPeerRegistry()
outcome::result< void > SeedGenesis(const std::vector< std::string > & genesis_peers, const std::vector< uint8_t > & ephemeral_signature)
Seeds the genesis trusted-peer list: proposes the genesis payload then adds exactly one ephemeral-bootstrapper signature. The signature is PRECOMPUTED – this method never signs live (D-02).
outcome::result< void > ProposeMembershipChange(const std::vector< std::string > & new_peers)
Proposes a membership-change value (new full peer list).
outcome::result< void > SignMembershipChange(const std::string & signer_address, const std::vector< uint8_t > & signature)
Adds a signature over the currently-proposed value.
outcome::result< bool > TryConfirm()
Attempts to confirm the currently-proposed value against quorum. On confirmation, decodes/verifies/applies the payload and overwrites the cached peer set – never speculatively before quorum is independently confirmed.
std::vector< std::string > GetCurrentPeers() const
Returns a copy of the current cached trusted-peer set.
bool IsGenesisConfirmed() const
Reports whether genesis has been confirmed.
void Unregister()
Unregisters this instance's signer-set-source from SecureCrdtRegistry (test-fixture teardown helper).
outcome::result< std::shared_ptr< TrustedPeerRegistry > > New(std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt, std::vector< std::string > genesis_peers, std::string bootstrapper_address, uint64_t quorum_threshold, sgns::crdt::HierarchicalKey base_key =sgns::crdt::HierarchicalKey("trusted-peer-registry"))
Constructs a TrustedPeerRegistry and registers its signer-set-source with SecureCrdtRegistry.

Public Functions Documentation

function TrustedPeerRegistry

TrustedPeerRegistry(
    std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt,
    std::vector< std::string > genesis_peers,
    std::string bootstrapper_address,
    uint64_t quorum_threshold,
    sgns::crdt::HierarchicalKey base_key
)

Constructs a TrustedPeerRegistry. The genesis peer list is cached immediately (D-05) –GetCurrentPeers() reflects it even before SeedGenesis/TryConfirm are called.

Parameters:

  • secure_crdt SecureCrdt wrapper to delegate propose/sign/ quorum operations to.
  • genesis_peers Genesis trusted-peer address list (non-empty).
  • bootstrapper_address Sole ephemeral genesis signer address.
  • quorum_threshold Quorum threshold applied once genesis is confirmed (i.e. for membership-change proposals).
  • base_key Registered CRDT key this instance owns.

function ~TrustedPeerRegistry

~TrustedPeerRegistry()

function SeedGenesis

outcome::result< void > SeedGenesis(
    const std::vector< std::string > & genesis_peers,
    const std::vector< uint8_t > & ephemeral_signature
)

Seeds the genesis trusted-peer list: proposes the genesis payload then adds exactly one ephemeral-bootstrapper signature. The signature is PRECOMPUTED – this method never signs live (D-02).

Parameters:

  • genesis_peers Genesis trusted-peer address list.
  • ephemeral_signature Precomputed bootstrapper signature over the genesis payload.

Return: outcome::success on success, or the first failing SecureCrdt call's error.

function ProposeMembershipChange

outcome::result< void > ProposeMembershipChange(
    const std::vector< std::string > & new_peers
)

Proposes a membership-change value (new full peer list).

Parameters:

  • new_peers Proposed new full trusted-peer address list.

Return: outcome::success on success, or the failing SecureCrdt call's error.

function SignMembershipChange

outcome::result< void > SignMembershipChange(
    const std::string & signer_address,
    const std::vector< uint8_t > & signature
)

Adds a signature over the currently-proposed value.

Parameters:

  • signer_address Address claimed to have produced signature.
  • signature Raw signature bytes.

Return: outcome::success on success, or the failing SecureCrdt call's error.

function TryConfirm

outcome::result< bool > TryConfirm()

Attempts to confirm the currently-proposed value against quorum. On confirmation, decodes/verifies/applies the payload and overwrites the cached peer set – never speculatively before quorum is independently confirmed.

Return: outcome::success(true) if this call newly confirmed a value, outcome::success(false) if quorum is not yet met, or a failure if the confirmed payload is malformed/invalid.

function GetCurrentPeers

std::vector< std::string > GetCurrentPeers() const

Returns a copy of the current cached trusted-peer set.

Return: Current trusted-peer address list.

function IsGenesisConfirmed

bool IsGenesisConfirmed() const

Reports whether genesis has been confirmed.

Return: true once TryConfirm has confirmed the genesis value.

function Unregister

void Unregister()

Unregisters this instance's signer-set-source from SecureCrdtRegistry (test-fixture teardown helper).

function New

static outcome::result< std::shared_ptr< TrustedPeerRegistry > > New(
    std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt,
    std::vector< std::string > genesis_peers,
    std::string bootstrapper_address,
    uint64_t quorum_threshold,
    sgns::crdt::HierarchicalKey base_key =sgns::crdt::HierarchicalKey("trusted-peer-registry")
)

Constructs a TrustedPeerRegistry and registers its signer-set-source with SecureCrdtRegistry.

Parameters:

  • secure_crdt SecureCrdt wrapper to delegate propose/sign/ quorum operations to.
  • genesis_peers Genesis trusted-peer address list (non-empty).
  • bootstrapper_address Sole ephemeral genesis signer address.
  • quorum_threshold Quorum threshold applied once genesis is confirmed.
  • base_key Registered CRDT key this instance owns.

Return: outcome::success(instance) with the newly-constructed, registered TrustedPeerRegistry instance, or outcome::failure(SecureCrdt::Error::QUORUM_THRESHOLD_BELOW_FLOOR) if quorum_threshold is below the majority-safety floor for genesis_peers.size() (D-07) – construction fails, no instance is produced.


Updated on 2026-08-07 at 17:48:02 +0000