mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-05-21 16:09:30 +00:00
eagerly send gossip at the end heartbeat
instead of trying to piggyback with outgoing messages
This commit is contained in:
parent
fc38f556a3
commit
f97d151aec
11
gossipsub.go
11
gossipsub.go
@ -833,10 +833,6 @@ func (gs *GossipSubRouter) heartbeat() {
|
|||||||
|
|
||||||
gs.heartbeatTicks++
|
gs.heartbeatTicks++
|
||||||
|
|
||||||
// flush pending control message from retries and gossip
|
|
||||||
// that hasn't been piggybacked since the last heartbeat
|
|
||||||
gs.flush()
|
|
||||||
|
|
||||||
tograft := make(map[peer.ID][]string)
|
tograft := make(map[peer.ID][]string)
|
||||||
toprune := make(map[peer.ID][]string)
|
toprune := make(map[peer.ID][]string)
|
||||||
noPX := make(map[peer.ID]bool)
|
noPX := make(map[peer.ID]bool)
|
||||||
@ -960,6 +956,9 @@ func (gs *GossipSubRouter) heartbeat() {
|
|||||||
// send coalesced GRAFT/PRUNE messages (will piggyback gossip)
|
// send coalesced GRAFT/PRUNE messages (will piggyback gossip)
|
||||||
gs.sendGraftPrune(tograft, toprune, noPX)
|
gs.sendGraftPrune(tograft, toprune, noPX)
|
||||||
|
|
||||||
|
// flush all pending gossip that wasn't piggybacked above
|
||||||
|
gs.flush()
|
||||||
|
|
||||||
// advance the message history window
|
// advance the message history window
|
||||||
gs.mcache.Shift()
|
gs.mcache.Shift()
|
||||||
}
|
}
|
||||||
@ -1081,14 +1080,14 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gs *GossipSubRouter) flush() {
|
func (gs *GossipSubRouter) flush() {
|
||||||
// send gossip first, which will also piggyback control
|
// send gossip first, which will also piggyback pending control
|
||||||
for p, ihave := range gs.gossip {
|
for p, ihave := range gs.gossip {
|
||||||
delete(gs.gossip, p)
|
delete(gs.gossip, p)
|
||||||
out := rpcWithControl(nil, ihave, nil, nil, nil)
|
out := rpcWithControl(nil, ihave, nil, nil, nil)
|
||||||
gs.sendRPC(p, out)
|
gs.sendRPC(p, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the remaining control messages
|
// send the remaining control messages that wasn't merged with gossip
|
||||||
for p, ctl := range gs.control {
|
for p, ctl := range gs.control {
|
||||||
delete(gs.control, p)
|
delete(gs.control, p)
|
||||||
out := rpcWithControl(nil, nil, nil, ctl.Graft, ctl.Prune)
|
out := rpcWithControl(nil, nil, nil, ctl.Graft, ctl.Prune)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user