Skip to content

Commit

Permalink
go/worker/common/p2p: Use explicit WithSeenMessagesTTL option
Browse files Browse the repository at this point in the history
This was introduced in go-libp2p-pubsub 0.7.0. The set value is
currently the same as the previous default but this makes it explicitly
in control of our P2P instance.
  • Loading branch information
kostko committed Jun 6, 2022
1 parent 818c179 commit c30f051
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .changelog/4782.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go: Bump libp2p to 0.20.1 and libp2p-pubsub to 0.7.0
15 changes: 11 additions & 4 deletions go/worker/common/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ import (
"github.com/oasisprotocol/oasis-core/go/worker/common/p2p/rpc"
)

// peersHighWatermarkDelta specifies how many peers after the maximum peer count is reached we ask
// the connection manager to start pruning peers.
const peersHighWatermarkDelta = 30
const (
// peersHighWatermarkDelta specifies how many peers after the maximum peer count is reached we
// ask the connection manager to start pruning peers.
peersHighWatermarkDelta = 30

// seenMessagesTTL is the amount of time pubsub messages will be remembered as seen and any
// duplicates will be dropped before propagation.
seenMessagesTTL = 120 * time.Second
)

// messageIdContext is the domain separation context for computing message identifier hashes.
var messageIdContext = []byte("oasis-core/p2p: message id")
Expand Down Expand Up @@ -298,7 +304,7 @@ func (p *p2p) RegisterProtocolServer(srv rpc.Server) {

// Implements api.Service.
func (p *p2p) GetMinRepublishInterval() time.Duration {
return pubsub.TimeCacheDuration + 5*time.Second
return seenMessagesTTL + 5*time.Second
}

func messageIdFn(pmsg *pb.Message) string {
Expand Down Expand Up @@ -443,6 +449,7 @@ func New(identity *identity.Identity, consensus consensus.Backend) (api.Service,
pubsub.WithValidateThrottle(viper.GetInt(CfgP2PValidateThrottle)),
pubsub.WithMessageIdFn(messageIdFn),
pubsub.WithDirectPeers(persistentPeersAI),
pubsub.WithSeenMessagesTTL(seenMessagesTTL),
)
if err != nil {
ctxCancel()
Expand Down

0 comments on commit c30f051

Please sign in to comment.