reputation/reputation_crdt.hpp¶
Last-Write-Wins CRDT for reputation synchronisation (PTDS §4.2) More...
Namespaces¶
| Name |
|---|
| sgns |
| sgns::neoswarm |
| sgns::neoswarm::reputation |
Classes¶
| Name | |
|---|---|
| class | sgns::neoswarm::reputation::ReputationCRDT Last-Write-Wins Register per node (PTDS §4.2). |
Detailed Description¶
Last-Write-Wins CRDT for reputation synchronisation (PTDS §4.2)
Date: 2026-05-06
Source code¶
#ifndef NEOSWARM_REPUTATION_REPUTATIONCRDT_HPP
#define NEOSWARM_REPUTATION_REPUTATIONCRDT_HPP
#include "node_reputation.hpp"
#include <mutex>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace sgns::neoswarm::reputation
{
class ReputationCRDT
{
public:
void Merge( const NodeReputation& remote );
std::optional<NodeReputation> Get( const std::string& identity_key ) const;
std::vector<NodeReputation> GetAll() const;
std::string Serialize() const;
void DeserializeAndMerge( const std::string& data );
private:
mutable std::mutex m_mutex;
std::unordered_map<std::string, NodeReputation> state_;
};
} // namespace sgns::neoswarm::reputation
#endif // NEOSWARM_REPUTATION_REPUTATIONCRDT_HPP
Updated on 2026-07-25 at 22:56:57 +0000