Skip to content

Commit 022b0d5

Browse files
chore: fixed lint errors
1 parent 6f64644 commit 022b0d5

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

rolling-shutter/p2p/floodsubpeerdiscovery/gossippeerdiscovery.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ type FloodsubPeerDiscovery struct {
2121
}
2222

2323
type PeerDiscoveryComponents struct {
24-
PeerId address.P2PIdentifier
24+
PeerID address.P2PIdentifier
2525
Pubsub *pubsub.PubSub
2626
PeerStore peerstore.Peerstore
2727
}
2828

2929
func (pd *FloodsubPeerDiscovery) Init(config PeerDiscoveryComponents, interval int, topics []string) error {
3030
pd.Interval = interval
31-
pd.PeerId = config.PeerId
31+
pd.PeerID = config.PeerID
3232
pd.Pubsub = config.Pubsub
3333
pd.PeerStore = config.PeerStore
3434

@@ -62,13 +62,18 @@ func (pd *FloodsubPeerDiscovery) Start(ctx context.Context) error {
6262
return err
6363
}
6464
case <-ctx.Done():
65+
for _, topic := range pd.Topics {
66+
if err := topic.Close(); err != nil {
67+
return fmt.Errorf("error in closing topic | %w", err)
68+
}
69+
}
6570
return nil
6671
}
6772
}
6873
}
6974

7075
func (pd *FloodsubPeerDiscovery) broadcast() error {
71-
pubKey, err := pd.PeerId.ExtractPublicKey()
76+
pubKey, err := pd.PeerID.ExtractPublicKey()
7277
if err != nil {
7378
return fmt.Errorf("peerId was missing public key | err %w", err)
7479
}
@@ -84,7 +89,7 @@ func (pd *FloodsubPeerDiscovery) broadcast() error {
8489

8590
addresses := make([][]byte, 0)
8691

87-
for _, addr := range pd.PeerStore.Addrs(pd.PeerId.ID) {
92+
for _, addr := range pd.PeerStore.Addrs(pd.PeerID.ID) {
8893
addresses = append(addresses, addr.Bytes())
8994
}
9095

@@ -94,7 +99,7 @@ func (pd *FloodsubPeerDiscovery) broadcast() error {
9499
}
95100
pbPeer, err := proto.Marshal(&peer)
96101
if err != nil {
97-
return fmt.Errorf("error marshalling message | err %w", err)
102+
return fmt.Errorf("error marshaling message | err %w", err)
98103
}
99104

100105
for _, topic := range pd.Topics {
@@ -107,7 +112,6 @@ func (pd *FloodsubPeerDiscovery) broadcast() error {
107112
if err := topic.Publish(context.Background(), pbPeer); err != nil {
108113
return fmt.Errorf("failed to publish to topic | err %w", err)
109114
}
110-
defer topic.Close()
111115
}
112116
return nil
113117
}

rolling-shutter/p2p/floodsubpeerdiscovery/peer.pb.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rolling-shutter/p2p/messaging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func New(config *Config) (*P2PMessaging, error) {
9999
Environment: config.Environment,
100100
DiscoveryNamespace: config.DiscoveryNamespace,
101101
IsAccessNode: config.IsAccessNode,
102-
FloodsubDiscovery: *&config.FloodSubDiscovery,
102+
FloodsubDiscovery: config.FloodSubDiscovery,
103103
}
104104

105105
bootstrapAddresses := config.CustomBootstrapAddresses

rolling-shutter/p2p/p2p.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,14 @@ func (p *P2PNode) Run(
136136
log.Info().Msg("floodsub peer discovery is enabled")
137137
p.FloodSubDiscovery = &floodsubpeerdiscovery.FloodsubPeerDiscovery{}
138138
peerDiscoveryComponents := floodsubpeerdiscovery.PeerDiscoveryComponents{
139-
PeerId: address.P2PIdentifier{p.host.ID()},
139+
PeerID: address.P2PIdentifier{ID: p.host.ID()},
140140
PeerStore: p.host.Peerstore(),
141141
Pubsub: p.pubSub,
142142
}
143-
p.FloodSubDiscovery.Init(peerDiscoveryComponents, p.config.FloodsubDiscovery.Interval, p.config.FloodsubDiscovery.Topics)
143+
err := p.FloodSubDiscovery.Init(peerDiscoveryComponents, p.config.FloodsubDiscovery.Interval, p.config.FloodsubDiscovery.Topics)
144+
if err != nil {
145+
return err
146+
}
144147
runner.Go(func() error {
145148
return p.FloodSubDiscovery.Start(ctx)
146149
})

0 commit comments

Comments
 (0)