Skip to content

Commit

Permalink
head node propagation can now also include signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
zees-dev committed Jun 15, 2024
1 parent 6336467 commit f72b962
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions node/aggregate/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ type Result struct {
Peers []peer.ID `json:"peers,omitempty"`
// How frequent was this result, in percentages.
Frequency float64 `json:"frequency,omitempty"`
// Signature of this result
Signature []byte `json:"signature,omitempty"`
}

type resultStats struct {
seen uint
peers []peer.ID
seen uint
peers []peer.ID
signature []byte
}

func Aggregate(results execute.ResultMap) Results {
Expand All @@ -40,13 +43,15 @@ func Aggregate(results execute.ResultMap) Results {
stat, ok := stats[output]
if !ok {
stats[output] = resultStats{
seen: 0,
peers: make([]peer.ID, 0),
seen: 0,
peers: make([]peer.ID, 0),
signature: res.Signature,
}
}

stat.seen++
stat.peers = append(stat.peers, executingPeer)
stat.signature = res.Signature

stats[output] = stat
}
Expand All @@ -59,6 +64,7 @@ func Aggregate(results execute.ResultMap) Results {
Result: res,
Peers: stat.peers,
Frequency: 100 * float64(stat.seen) / float64(total),
Signature: stat.signature,
}

aggregated = append(aggregated, aggr)
Expand Down

0 comments on commit f72b962

Please sign in to comment.