Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pubsub topic to WakuMessageKeyValue #1097

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 66 additions & 55 deletions waku/v2/protocol/store/pb/storev3.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions waku/v2/protocol/store/pb/storev3.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "waku/message/v1/message.proto";
message WakuMessageKeyValue {
optional bytes message_hash = 1; // Globally unique key for a Waku Message
optional waku.message.v1.WakuMessage message = 2; // Full message content as value
optional string pubsub_topic = 3;
richard-ramos marked this conversation as resolved.
Show resolved Hide resolved
}

message StoreQueryRequest {
Expand Down
9 changes: 5 additions & 4 deletions waku/v2/protocol/store/pb/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var (
errMaxContentTopics = errors.New("exceeds the maximum number of ContentTopics allowed")
errEmptyContentTopic = errors.New("one or more content topics specified is empty")
errMissingPubsubTopic = errors.New("missing PubsubTopic field")
errMissingContentTopics = errors.New("missing ContentTopics field")
errMissingStatusCode = errors.New("missing StatusCode field")
errInvalidTimeRange = errors.New("invalid time range")
errInvalidMessageHash = errors.New("invalid message hash")
Expand All @@ -40,9 +39,7 @@ func (x *StoreQueryRequest) Validate() error {
return errMissingPubsubTopic
}

if len(x.ContentTopics) == 0 {
return errMissingContentTopics
} else if len(x.ContentTopics) > MaxContentTopics {
if len(x.ContentTopics) > MaxContentTopics {
return errMaxContentTopics
} else {
for _, m := range x.ContentTopics {
Expand Down Expand Up @@ -83,6 +80,10 @@ func (x *WakuMessageKeyValue) Validate() error {
}

if x.Message != nil {
if x.GetPubsubTopic() == "" {
return errMissingPubsubTopic
}

return x.Message.Validate()
}

Expand Down
4 changes: 0 additions & 4 deletions waku/v2/protocol/store/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ func (r *Result) Query() *pb.StoreQueryRequest {
return r.storeRequest
}

func (r *Result) PubsubTopic() string {
return r.storeRequest.GetPubsubTopic()
}

func (r *Result) Next(ctx context.Context) (bool, error) {
if !r.started {
r.started = true
Expand Down
Loading