Skip to content

Commit

Permalink
small alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Nov 17, 2023
1 parent 6a606d8 commit 6db2a1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
37 changes: 19 additions & 18 deletions core/gossip/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
)

func GossipSubParams(overlayp *commons.OverlayParams) pubsub.GossipSubParams {
// GossipSubParams returns the default pubsub.GossipSubParams parameters,
// overriden by the given overlay parameters.
func GossipSubParams(overlayParams *commons.OverlayParams) pubsub.GossipSubParams {
gsCfg := pubsub.DefaultGossipSubParams()
var overlay commons.OverlayParams
if overlayp != nil {
overlay = *overlayp
if overlayParams == nil {
return gsCfg
}
if overlay.D > 0 {
gsCfg.D = int(overlay.D)
if overlayParams.D > 0 {
gsCfg.D = int(overlayParams.D)
}
if overlay.Dlow > 0 {
gsCfg.Dlo = int(overlay.Dlow)
if overlayParams.Dlow > 0 {
gsCfg.Dlo = int(overlayParams.Dlow)
}
if overlay.Dhi > 0 {
gsCfg.Dhi = int(overlay.Dhi)
if overlayParams.Dhi > 0 {
gsCfg.Dhi = int(overlayParams.Dhi)
}
if overlay.Dlazy > 0 {
gsCfg.Dlazy = int(overlay.Dlazy)
if overlayParams.Dlazy > 0 {
gsCfg.Dlazy = int(overlayParams.Dlazy)
}
if overlay.McacheGossip > 0 {
gsCfg.MaxIHaveMessages = int(overlay.McacheGossip)
if overlayParams.McacheGossip > 0 {
gsCfg.MaxIHaveMessages = int(overlayParams.McacheGossip)
}
if overlay.McacheLen > 0 {
gsCfg.MaxIHaveLength = int(overlay.McacheLen)
if overlayParams.McacheLen > 0 {
gsCfg.MaxIHaveLength = int(overlayParams.McacheLen)
}
if fanoutTtl := overlay.FanoutTtl; fanoutTtl.Milliseconds() > 0 {
if fanoutTtl := overlayParams.FanoutTtl; fanoutTtl.Milliseconds() > 0 {
gsCfg.FanoutTTL = fanoutTtl
}
if heartbeat := overlay.HeartbeatInterval; heartbeat.Milliseconds() > 0 {
if heartbeat := overlayParams.HeartbeatInterval; heartbeat.Milliseconds() > 0 {
gsCfg.HeartbeatInterval = heartbeat
}
return gsCfg
Expand Down
3 changes: 2 additions & 1 deletion core/gossip/scoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ func PeerScores(cfg commons.PubsubConfig) (*pubsub.PeerScoreParams, *pubsub.Peer
peerScores, thresholds := &pubsub.PeerScoreParams{}, &pubsub.PeerScoreThresholds{
// TODO: using reasonable defaults, requires tuning
SkipAtomicValidation: true,
GossipThreshold: -10000,
GossipThreshold: -4000,
PublishThreshold: -2000,
GraylistThreshold: -400,
// OpportunisticGraftThreshold: 10,
}
if cfg.Scoring != nil {
s, t := cfg.Scoring.ToStd()
Expand Down

0 comments on commit 6db2a1a

Please sign in to comment.