don't send messages to self

This commit is contained in:
Dmitriy Ryajov 2019-10-02 15:43:00 -06:00
parent 31c7dd38b8
commit 6cfbf2c124
1 changed files with 3 additions and 1 deletions

View File

@ -69,6 +69,7 @@ proc rpcHandler(f: FloodSub,
# send subscriptions to every peer
for p in f.peers.values:
# if p.id != peer.id:
await p.send(@[RPCMsg(subscriptions: m.subscriptions)])
var toSendPeers: HashSet[string] = initSet[string]()
@ -82,7 +83,8 @@ proc rpcHandler(f: FloodSub,
# forward the message to all peers interested in it
for p in toSendPeers:
await f.peers[p].send(@[RPCMsg(messages: m.messages)])
if f.peers[p].id != peer.id:
await f.peers[p].send(@[RPCMsg(messages: m.messages)])
proc handleConn(f: FloodSub,
conn: Connection) {.async, gcsafe.} =