Skip to content

Commit 6911b90

Browse files
Merge pull request #518 from shutter-network/feature/access-node-pubsub-config
feat: added a flag for isAccessNode and updated pubsub config
2 parents 131e353 + 4112c7d commit 6911b90

File tree

6 files changed

+15
-0
lines changed

6 files changed

+15
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ log
88
node_modules
99
result
1010
temp
11+
work

rolling-shutter/gnosisaccessnode/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ func (c *Config) Validate() error {
4242
}
4343

4444
func (c *Config) SetDefaultValues() error {
45+
c.P2P.IsAccessNode = true
4546
return nil
4647
}
4748

4849
func (c *Config) SetExampleValues() error { //nolint:unparam
50+
err := c.SetDefaultValues()
51+
if err != nil {
52+
return err
53+
}
4954
c.InstanceID = 1000
5055
c.MaxNumKeysPerMessage = 500
5156
return nil

rolling-shutter/p2p/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Config struct {
4747
CustomBootstrapAddresses []*address.P2PAddress `comment:"Overwrite p2p boostrap nodes"`
4848
Environment env.Environment
4949
DiscoveryNamespace string `shconfig:",required" comment:"Must be unique for each instance id."`
50+
IsAccessNode bool `comment:"Optional, to be set to true if running an access node"`
5051
}
5152

5253
func (c *Config) Name() string {

rolling-shutter/p2p/messaging.go

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func New(config *Config) (*P2PMessaging, error) {
9898
PrivKey: *config.P2PKey,
9999
Environment: config.Environment,
100100
DiscoveryNamespace: config.DiscoveryNamespace,
101+
IsAccessNode: config.IsAccessNode,
101102
}
102103

103104
bootstrapAddresses := config.CustomBootstrapAddresses

rolling-shutter/p2p/p2p.go

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type p2pNodeConfig struct {
6969
PrivKey keys.Libp2pPrivate
7070
Environment env.Environment
7171
IsBootstrapNode bool
72+
IsAccessNode bool
7273
DiscoveryNamespace string
7374
}
7475

@@ -264,6 +265,7 @@ func createPubSub(
264265
gossipSubParams, peerScoreParams, peerScoreThresholds := makePubSubParams(pubSubParamsOptions{
265266
isBootstrapNode: config.IsBootstrapNode,
266267
bootstrapPeers: config.BootstrapPeers,
268+
isAccessNode: config.IsAccessNode,
267269
})
268270

269271
pubsubOptions := []pubsub.Option{

rolling-shutter/p2p/params.go

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
type pubSubParamsOptions struct {
1111
isBootstrapNode bool
12+
isAccessNode bool
1213
bootstrapPeers []peer.AddrInfo
1314
}
1415

@@ -35,6 +36,10 @@ func makePubSubParams(
3536
gossipSubParams.Dscore = 0
3637
}
3738

39+
if options.isAccessNode {
40+
gossipSubParams.Dhi = 30
41+
}
42+
3843
peerScoreThresholds := &pubsub.PeerScoreThresholds{
3944
GossipThreshold: -4000,
4045
PublishThreshold: -8000,

0 commit comments

Comments
 (0)