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

chore: using msg hash in hex and adding store test #16

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

gabrielmer
Copy link
Collaborator

@gabrielmer gabrielmer commented Jan 16, 2025

Adapting the codebase to the usage of message hashes as hex strings in Relay and Store.

Included a new MessageHash type which is used whenever the bindings interact with message hashes, and added a test for Store.

A PR in nwaku returning message hashes in hex was also opened: waku-org/nwaku#3234

@@ -347,6 +345,7 @@ type WakuConfig struct {
Nodekey string `json:"nodekey,omitempty"`
Relay bool `json:"relay,omitempty"`
Store bool `json:"store,omitempty"`
LegacyStore bool `json:"legacyStore"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I didn't add the omitempty because if we set it manually to false, it is considered empty and not sent. But the default in nwaku is true, and therefore we need to explicitly send it whenever is set to false

@gabrielmer gabrielmer requested review from Ivansete-status and richard-ramos and removed request for Ivansete-status January 16, 2025 18:44

func ToMessageHash(val string) (MessageHash, error) {
if len(val) == 0 {
return "", fmt.Errorf("empty string not allowed")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no formatting is being used, you can use errors.New("empty string not allowed") here and line 17

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh good catch! It was either a copy-paste mistake, or it was written by AI and didn't notice that mistake - don't remember lol

TimeStart *int64 `json:"time_start,omitempty"`
TimeEnd *int64 `json:"time_end,omitempty"`
MessageHashes *[]MessageHash `json:"message_hashes,omitempty"`
PaginationCursor MessageHash `json:"pagination_cursor,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be *MessageHash?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Forgot that it was optional. Updated it :)

}

type StoreMessageResponse struct {
WakuMessage tmpWakuMessageJson `json:"message"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messages are optional and only included if include_data is true, so WakuMessage should be a pointer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Changed it :)

@gabrielmer gabrielmer force-pushed the chore-using-msg-hash-in-hex branch from c0cca31 to be664cd Compare January 17, 2025 16:52
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for it! 💯
I'm just adding a nitpick comment ;P

)

// MessageHash represents an unique identifier for a message within a pubsub topic
type MessageHash string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not strictly correct. A message hash is array[byte, 32]
I'd happier if we rename it a little ;P

Suggested change
type MessageHash string
type MessageHashHexStr string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants