Skip to content

sgns::neoswarm::reputation::ReputationCRDT

Last-Write-Wins Register per node (PTDS §4.2). More...

#include <reputation_crdt.hpp>

Public Functions

Name
void Merge(const NodeReputation & remote)
Apply a remote reputation update (merge).
std::optional< NodeReputation > Get(const std::string & identity_key) const
Get the current merged state for a node.
std::vector< NodeReputation > GetAll() const
Get all merged reputation records.
std::string Serialize() const
Serialise the full CRDT state for network transmission.
void DeserializeAndMerge(const std::string & data)
Deserialise and merge a received CRDT state.

Detailed Description

class sgns::neoswarm::reputation::ReputationCRDT;

Last-Write-Wins Register per node (PTDS §4.2).

Merge rule: keep the entry with the highest m_lastUpdatedMs timestamp. Designed to be replicated across nodes via libp2p GossipSub.

Public Functions Documentation

function Merge

void Merge(
    const NodeReputation & remote
)

Apply a remote reputation update (merge).

Parameters:

  • remote Reputation record received from a peer.

function Get

std::optional< NodeReputation > Get(
    const std::string & identity_key
) const

Get the current merged state for a node.

Parameters:

  • identity_key Node identity key.

Return: NodeReputation if known, std::nullopt otherwise.

function GetAll

std::vector< NodeReputation > GetAll() const

Get all merged reputation records.

Return: Vector of all known records.

function Serialize

std::string Serialize() const

Serialise the full CRDT state for network transmission.

Return: CSV-encoded state string.

function DeserializeAndMerge

void DeserializeAndMerge(
    const std::string & data
)

Deserialise and merge a received CRDT state.

Parameters:

  • data CSV-encoded state string from a peer.

Updated on 2026-10-09 at 03:59:42 +0000