-
Notifications
You must be signed in to change notification settings - Fork 14
14-WAKU2-MESSAGE: Data type and resolution of timestamp #448
Comments
Update:
There is also the use of the I still could not find a use of unit64 with sub-seconds resolution. |
Further Updates: The Unix timestamp is commonly known and calculated as
The implementation of Twitter pagination and Facebook time-based pagination also adheres to the seconds resolution. From my point of view and based on the research I have done so far, it is up to us to decide on our preferred time resolution and also be clear about that in the specs. |
@jm-clius @D4nte @richard-ramos thoughts/comments? |
For what is worth, in Go I do have access to the unix epoch in seconds and nanoseconds, althought both of them are int64.
In order to support the float64 timestamps that WakuMessage has, I need to perform this conversion: theTime := time.Now().UnixNano()
result: float64(theTime) / float64(time.Second) |
I see! Then the use of |
Some other inputs from nimbus dev-helpdesk:
Thus int64/uint64 is a more meaningful and common choice for time (but not float values). We are getting to a consensus re the data type; which should be uint or int. Also, re being unsigned or signed, signed is a safer choice and avoids arithmetic bugs. |
@kdeme thoughts from Nim POV? Was there a specific rationale for:
|
FYI JS uses milliseconds since epoch (integer): https://www.w3schools.com/jsref/jsref_gettime.asp Howevever, I don't think it should have an influence on the decision. No other thoughts/comments from my side. |
The peer pool code linked is not discovery v5 code and much older and not the best example to look at nowadays. In discoveryv5 (and probably in most more recent code in general) we use chronos I guess it depends on what the timestamp is used for, but for the cases linked in nim-eth code I believe it is the better and more simple way to store/transfer the "timestamp" (they are really used as a moment, to compare with another moment in time). It is stored as int64 so that sets you safe, and also gives nanosecond resolution if you need that (which is not needed in these cases but ok). If you do need a more humanly representable format, you can just do a conversion. The discv4 and nim-eth p2p code should be altered to also use this. |
Closing the issue since it has been addressed in waku-org/nwaku#834 |
Problem
The data type of timestamp in Waku2 (Wakumessage and in the store protocol) is set to float64, which represents seconds in the integer part and sub-seconds in the fractional part. However, this is not certain whether float64 is an appropriate type or int64 shall be used instead. Another question is also about the desired resolution i.e., seconds only or sub-seconds.
Opened the issue to address the following comment #406 (comment)
cc: @oskarth
Acceptance Criteria
The text was updated successfully, but these errors were encountered: