-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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"` |
There was a problem hiding this comment.
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
waku/common/message_hash.go
Outdated
|
||
func ToMessageHash(val string) (MessageHash, error) { | ||
if len(val) == 0 { | ||
return "", fmt.Errorf("empty string not allowed") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
waku/common/store.go
Outdated
TimeStart *int64 `json:"time_start,omitempty"` | ||
TimeEnd *int64 `json:"time_end,omitempty"` | ||
MessageHashes *[]MessageHash `json:"message_hashes,omitempty"` | ||
PaginationCursor MessageHash `json:"pagination_cursor,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be *MessageHash
?
There was a problem hiding this comment.
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 :)
waku/common/store.go
Outdated
} | ||
|
||
type StoreMessageResponse struct { | ||
WakuMessage tmpWakuMessageJson `json:"message"` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True! Changed it :)
c0cca31
to
be664cd
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
type MessageHash string | |
type MessageHashHexStr string |
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