-
Notifications
You must be signed in to change notification settings - Fork 56
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: sending msg hash as string on libwaku message event #3234
base: master
Are you sure you want to change the base?
chore: sending msg hash as string on libwaku message event #3234
Conversation
You can find the image built from this PR at
Built from 9fda9e4 |
@gabrielmer - ah, sorry but I can't approve that one now, unless you convince me hehe. I think is fine passing the |
Well, I don't know if I can convince you about the change itself, but at least I might be able to convince you that the opposite is true of what you mentioned - dealing with a string is more efficient than dealing with the byte array lol. If you see, the events are not serialized and deserialized, they are sent as a json-string: Lines 92 to 95 in 625c8ee
In other words, when we send that byte-array, we are sending the string representation of a byte array, not the bytes directly. The host has to then parse that string, convert it to an actual byte array and then convert it to the string representation of the hash. It's both less efficient and it adds extra/unnecessary work from the host's code to have to parse the string representation of a byte array |
@gabrielmer - you are absolutely right my friend. I think I'm starting to get convinced ;P |
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.
Approving after the agreement to focus on retrieving all the information from libwaku in the most readable format, by default :)
Moving this PR back to draft, will reopen it for review once the hex string format is used all across libwaku and REST |
90658a6
to
79a69a7
Compare
6ac0948
to
e0e9f18
Compare
@@ -59,7 +59,7 @@ proc `%`*(value: Base64String): JsonNode = | |||
|
|||
type JsonMessageEvent* = ref object of JsonEvent | |||
pubsubTopic*: string | |||
messageHash*: WakuMessageHash | |||
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.
Maybe it's better to define a WakuMessageHashHex
or HexString
type and use it instead of just string?
LMK if it makes sense and if it adds value
Description
As previously discussed, it makes more sense for application clients to use message hashes as hex strings instead of a string representation of a byte array.
In this PR, we're modifying the usage of message hashes in libwaku and in the REST API to receive and return the message hashes as hex strings. This change only applies for the interactions with the message hashes and with pagination cursors (which are themselves message hashes). Everything else remains untouched and other fields such as payload and meta are still sent as base64 strings.
Changes
WakuMessageKeyValueHex
andStoreQueryResponseHex
types to be used when interacting with application clientsJsonMessageEvent
andwaku_store_query
as hex stringsA PR updating the REST API's docs will be opened once this PR is merged. Or shall we define a new endpoint for backward compatibility? Another option is to accept both byte arrays and hex strings in the API and check in the endpoint which one it is
Issue
#3076