From 4d5d764710e203b99589a5e6af1e0cc2b6ddff34 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 23 Feb 2022 13:39:49 +1100 Subject: [PATCH] Add `timestamp` nanoseconds field https://github.com/vacp2p/rfc/pull/483 https://github.com/vacp2p/rfc/pull/491 --- src/lib/waku_message/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/waku_message/index.ts b/src/lib/waku_message/index.ts index a42325b692..d683df8405 100644 --- a/src/lib/waku_message/index.ts +++ b/src/lib/waku_message/index.ts @@ -104,6 +104,8 @@ export class WakuMessage { { payload: _payload, timestampDeprecated: timestamp.valueOf() / 1000, + // nanoseconds https://rfc.vac.dev/spec/14/ + timestamp: timestamp.valueOf() * 1000, version, contentTopic, }, @@ -270,6 +272,11 @@ export class WakuMessage { } get timestamp(): Date | undefined { + if (this.proto.timestamp) { + // nanoseconds https://rfc.vac.dev/spec/14/ + return new Date(this.proto.timestamp / 1000); + } + if (this.proto.timestampDeprecated) { return new Date(this.proto.timestampDeprecated * 1000); }