@@ -13,9 +13,10 @@ type p2pNode struct {
1313 nodeLatency float64
1414 edges map [PeerID ]p2pEdge
1515
16- recvFrom map [string ]map [PeerID ]struct {} // content -> set of senders
17- sentTo map [string ]map [PeerID ]struct {} // content -> set of targets
18- seenAt map [string ]time.Time // content -> first arrival time
16+ recvFrom map [string ]map [PeerID ]struct {} // content -> set of senders
17+ sentTo map [string ]map [PeerID ]struct {} // content -> set of targets
18+ seenAt map [string ]time.Time // content -> first arrival time
19+ firstFrom map [string ]PeerID // content -> first sender
1920
2021 msgQueue chan Message
2122 mu sync.Mutex
@@ -36,9 +37,10 @@ func newNode(id PeerID, nodeLatency float64) *p2pNode {
3637 nodeLatency : nodeLatency ,
3738 edges : make (map [PeerID ]p2pEdge ),
3839
39- recvFrom : make (map [string ]map [PeerID ]struct {}),
40- sentTo : make (map [string ]map [PeerID ]struct {}),
41- seenAt : make (map [string ]time.Time ),
40+ recvFrom : make (map [string ]map [PeerID ]struct {}),
41+ sentTo : make (map [string ]map [PeerID ]struct {}),
42+ seenAt : make (map [string ]time.Time ),
43+ firstFrom : make (map [string ]PeerID ),
4244
4345 msgQueue : make (chan Message , 1000 ),
4446 mu : sync.Mutex {},
@@ -67,6 +69,7 @@ func (n *p2pNode) eachRun(network *P2P, wg *sync.WaitGroup, ctx context.Context)
6769
6870 if _ , ok := n .seenAt [msg .Content ]; ! ok {
6971 n .seenAt [msg .Content ] = time .Now ()
72+ n .firstFrom [msg .Content ] = msg .From
7073 first = true
7174 }
7275 n .mu .Unlock ()
0 commit comments