mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-08 15:53:07 +00:00
harden piggybackControl
don't create a control object if the graft/prune are stale and only assign the relevant fields.
This commit is contained in:
parent
bfb0664581
commit
009efebdaf
12
gossipsub.go
12
gossipsub.go
@ -520,14 +520,22 @@ func (gs *GossipSubRouter) piggybackControl(p peer.ID, out *RPC, ctl *pb.Control
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(tograft) == 0 && len(toprune) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
xctl := out.Control
|
xctl := out.Control
|
||||||
if xctl == nil {
|
if xctl == nil {
|
||||||
xctl = &pb.ControlMessage{}
|
xctl = &pb.ControlMessage{}
|
||||||
out.Control = xctl
|
out.Control = xctl
|
||||||
}
|
}
|
||||||
|
|
||||||
xctl.Graft = append(xctl.Graft, tograft...)
|
if len(tograft) > 0 {
|
||||||
xctl.Prune = append(xctl.Prune, toprune...)
|
xctl.Graft = append(xctl.Graft, tograft...)
|
||||||
|
}
|
||||||
|
if len(toprune) > 0 {
|
||||||
|
xctl.Prune = append(xctl.Prune, toprune...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gs *GossipSubRouter) getPeers(topic string, count int, filter func(peer.ID) bool) []peer.ID {
|
func (gs *GossipSubRouter) getPeers(topic string, count int, filter func(peer.ID) bool) []peer.ID {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user