Skip to content

Commit

Permalink
chore: remove deprecated field usage and check for light mode only if…
Browse files Browse the repository at this point in the history
… shards are not present
  • Loading branch information
chaitanyaprem committed Jul 15, 2024
1 parent 2f333c1 commit 6c07039
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions waku/v2/protocol/metadata/waku_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func (wakuM *WakuMetadata) Request(ctx context.Context, peerID peer.ID) (*pb.Wak
request := &pb.WakuMetadataRequest{}
request.ClusterId = clusterID
request.Shards = shards
// TODO: remove with nwaku 0.28 deployment
request.ShardsDeprecated = shards // nolint: staticcheck

writer := pbio.NewDelimitedWriter(stream)
reader := pbio.NewDelimitedReader(stream, math.MaxInt32)
Expand Down Expand Up @@ -173,8 +171,6 @@ func (wakuM *WakuMetadata) onRequest(ctx context.Context) func(network.Stream) {
} else {
response.ClusterId = clusterID
response.Shards = shards
// TODO: remove with nwaku 0.28 deployment
response.ShardsDeprecated = shards // nolint: staticcheck
}

err = writer.WriteMsg(response)
Expand Down Expand Up @@ -245,14 +241,6 @@ func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
rClusterID := uint16(*response.ClusterId)
var rs protocol.RelayShards

if _, err = wakuM.h.Peerstore().SupportsProtocols(peerID, relay.WakuRelayID_v200); err == nil {
wakuM.log.Debug("light peer only checking clusterID")
if rClusterID != wakuM.clusterID {
wakuM.disconnectPeer(peerID, errors.New("different clusterID reported"))
}
return
}

wakuM.log.Debug("relay peer checking cluster and shards")

var rShardIDs []uint16
Expand All @@ -261,9 +249,12 @@ func (wakuM *WakuMetadata) Connected(n network.Network, cc network.Conn) {
rShardIDs = append(rShardIDs, uint16(i))
}
} else {
// TODO: remove with nwaku 0.28 deployment
for _, i := range response.ShardsDeprecated { // nolint: staticcheck
rShardIDs = append(rShardIDs, uint16(i))
if _, err = wakuM.h.Peerstore().SupportsProtocols(peerID, relay.WakuRelayID_v200); err == nil {
wakuM.log.Debug("light peer only checking clusterID")
if rClusterID != wakuM.clusterID {
wakuM.disconnectPeer(peerID, errors.New("different clusterID reported"))
}
return
}
}
wakuM.log.Debug("getting remote cluster and shards")
Expand Down

0 comments on commit 6c07039

Please sign in to comment.