Reputation Aggregator is a struct that collects reputation changes and sends them in on batch to relieve network channels, needed for Statement Distributionsubsystem
This struct should be placed at parachains/utils folder since it should be available for more than one subsystem.
The struct:
type ReputationAggregator struct {
// a function that helps the aggregator to understand if such reputation should be dispatched to network subsystems at arrival or can stay longer in the batch
sendImmediatellyIf func(rep UnifiedReputationChange) bool
byPeer map[peer.ID]int32
}
// effectivelly sends the collected reputations to the network subsystem
type (r *ReputationAggregator) Send(overseerCh) {
overseerCh <- NetworkBridgeTxMessage {
ReportPeerMessageBatch: r.byPeer
}
// clear the map after sending
r.byPeer = map[peer.ID]int32{}
}
type (r *ReputationAggregator) Modify(overseerCh, peerID, rep) {
if r.sendImmediatellyIf(rep) {
// send rep w/o adding to the aggregator
}
// add to the aggregator
}
Description
Reputation Aggregator is a struct that collects reputation changes and sends them in on batch to relieve network channels, needed for
Statement Distribution
subsystemThis struct should be placed at
parachains/utils
folder since it should be available for more than one subsystem.The struct:
Links