fix_: proper content topic conversion between transport and waku layer for setting criteria interest (#5758)

This commit is contained in:
richΛrd 2024-08-21 13:45:32 -04:00 committed by GitHub
parent 8914a79284
commit 36c893d3d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 9 deletions

View File

@ -129,7 +129,7 @@ func (w *GethWakuWrapper) SubscribeToConnStatusChanges() (*types.ConnStatusSubsc
return nil, errors.New("not available in WakuV1")
}
func (w *GethWakuWrapper) SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []string) error {
func (w *GethWakuWrapper) SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []types.TopicType) error {
return errors.New("not available in WakuV1")
}

View File

@ -302,9 +302,13 @@ func (w *gethWakuV2Wrapper) SubscribeToConnStatusChanges() (*types.ConnStatusSub
return w.waku.SubscribeToConnStatusChanges(), nil
}
func (w *gethWakuV2Wrapper) SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []string) error {
func (w *gethWakuV2Wrapper) SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []types.TopicType) error {
var cTopics []string
for _, ct := range contentTopics {
cTopics = append(cTopics, wakucommon.TopicType(ct).ContentTopic())
}
pubsubTopic = w.waku.GetPubsubTopic(pubsubTopic)
w.waku.SetTopicsToVerifyForMissingMessages(peerID, pubsubTopic, contentTopics)
w.waku.SetTopicsToVerifyForMissingMessages(peerID, pubsubTopic, cTopics)
// No err can be be generated by this function. The function returns an error
// Just so there's compatibility with GethWakuWrapper from V1

View File

@ -30,7 +30,7 @@ func BytesToTopic(b []byte) (t TopicType) {
}
// String converts a topic byte array to a string representation.
func (t *TopicType) String() string {
func (t TopicType) String() string {
return EncodeHex(t[:])
}

View File

@ -141,7 +141,7 @@ type Waku interface {
SubscribeToConnStatusChanges() (*ConnStatusSubscription, error)
SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []string) error
SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []TopicType) error
// MinPow returns the PoW value required by this node.
MinPow() float64

View File

@ -752,7 +752,7 @@ func (t *Transport) SetCriteriaForMissingMessageVerification(peerID peer.ID, fil
return
}
topicMap := make(map[string]map[string]struct{})
topicMap := make(map[string]map[types.TopicType]struct{})
for _, f := range filters {
if !f.Listen || f.Ephemeral {
continue
@ -760,10 +760,10 @@ func (t *Transport) SetCriteriaForMissingMessageVerification(peerID peer.ID, fil
_, ok := topicMap[f.PubsubTopic]
if !ok {
topicMap[f.PubsubTopic] = make(map[string]struct{})
topicMap[f.PubsubTopic] = make(map[types.TopicType]struct{})
}
topicMap[f.PubsubTopic][f.ContentTopic.String()] = struct{}{}
topicMap[f.PubsubTopic][f.ContentTopic] = struct{}{}
}
for pubsubTopic, contentTopics := range topicMap {
@ -774,7 +774,7 @@ func (t *Transport) SetCriteriaForMissingMessageVerification(peerID peer.ID, fil
zap.Error(err),
zap.Stringer("peerID", peerID),
zap.String("pubsubTopic", pubsubTopic),
zap.Strings("contentTopics", ctList))
zap.Stringers("contentTopics", ctList))
return
}
}