mirror of
https://github.com/status-im/js-waku.git
synced 2025-02-23 10:28:15 +00:00
WakuMessage.timestamp
field must use nanoseconds (#606)
This commit is contained in:
parent
2798376776
commit
e649f772a7
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Handle errors thrown by `bytesToUtf8`.
|
- Handle errors thrown by `bytesToUtf8`.
|
||||||
|
- `WakuMessage.timestamp` field must use nanoseconds (was using microseconds).
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ export class WakuMessage {
|
|||||||
{
|
{
|
||||||
payload: _payload,
|
payload: _payload,
|
||||||
timestampDeprecated: timestamp.valueOf() / 1000,
|
timestampDeprecated: timestamp.valueOf() / 1000,
|
||||||
// nanoseconds https://rfc.vac.dev/spec/14/
|
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||||
timestamp: Long.fromNumber(timestamp.valueOf()).mul(1000),
|
timestamp: Long.fromNumber(timestamp.valueOf()).mul(1_000_000),
|
||||||
version,
|
version,
|
||||||
contentTopic,
|
contentTopic,
|
||||||
},
|
},
|
||||||
@ -281,8 +281,8 @@ export class WakuMessage {
|
|||||||
// we catch the error and return undefined.
|
// we catch the error and return undefined.
|
||||||
try {
|
try {
|
||||||
if (this.proto.timestamp) {
|
if (this.proto.timestamp) {
|
||||||
// nanoseconds https://rfc.vac.dev/spec/14/
|
// nanoseconds 10^-9 to milliseconds 10^-3
|
||||||
const timestamp = this.proto.timestamp.div(1000).toNumber();
|
const timestamp = this.proto.timestamp.div(1_000_000).toNumber();
|
||||||
return new Date(timestamp);
|
return new Date(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +107,17 @@ export class HistoryRPC {
|
|||||||
} as protoV2Beta4.PagingInfo;
|
} as protoV2Beta4.PagingInfo;
|
||||||
|
|
||||||
let startTime, endTime;
|
let startTime, endTime;
|
||||||
if (params.startTime)
|
if (params.startTime) {
|
||||||
startTime = Long.fromNumber(params.startTime.valueOf()).mul(1000);
|
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||||
|
startTime = Long.fromNumber(params.startTime.valueOf()).mul(
|
||||||
if (params.endTime)
|
1_000_000
|
||||||
endTime = Long.fromNumber(params.endTime.valueOf()).mul(1000);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.endTime) {
|
||||||
|
// milliseconds 10^-3 to nanoseconds 10^-9
|
||||||
|
endTime = Long.fromNumber(params.endTime.valueOf()).mul(1_000_000);
|
||||||
|
}
|
||||||
return new HistoryRPC(
|
return new HistoryRPC(
|
||||||
{
|
{
|
||||||
requestId: uuid(),
|
requestId: uuid(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user