Skip to main content

Module peer_reputation_graph

Module peer_reputation_graph 

Source
Expand description

Peer Reputation Graph with trust propagation and reputation scoring.

This module provides a graph-based peer reputation system that models trust relationships between peers as weighted directed edges. Trust propagates transitively through the graph (up to a configurable depth), enabling reputation to be inferred even for peers with limited direct interaction.

§Design

The graph stores:

  • Direct scores – updated by explicit positive/negative interactions via an exponential moving average (EMA).
  • Propagated scores – computed by multi-hop BFS, damping trust at each hop, so peers trusted by highly-reputed peers inherit some of that trust.
  • Combined scores – a configurable linear blend of the two.

All floating-point arithmetic avoids unwrap() and clamps values to [0.0, 1.0] to maintain invariants.

§Examples

use ipfrs_network::peer_reputation_graph::{PeerReputationGraph, GraphConfig};

let config = GraphConfig::default();
let mut graph = PeerReputationGraph::new(config);

graph.add_peer("alice".to_string()).unwrap();
graph.add_peer("bob".to_string()).unwrap();
graph.add_edge("alice", "bob", 0.8).unwrap();

let event = graph.record_interaction("alice", true, 0.5).unwrap();
let _updated = graph.propagate_trust();

let score = graph.reputation("bob").unwrap();
println!("Bob combined score: {:.3}", score.combined_score);

Structs§

GraphConfig
Configuration parameters for PeerReputationGraph.
GraphStats
Aggregate statistics for the entire reputation graph.
PeerReputationGraph
Graph-based peer reputation system with trust propagation.
ReputationScore
A full reputation snapshot for a single peer.
TrustEdge
A directed weighted trust edge between two peers.

Enums§

GraphError
Errors that can arise when working with the PeerReputationGraph.
ReputationEvent
Events emitted by the reputation graph for observability.