git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 8a6dee20553eb2c7dc78f6ae843306099b24b093

Files: 8a6dee20553eb2c7dc78f6ae843306099b24b093 / message / sync / timestamp.js

595 bytesRaw
1var nest = require('depnest')
2
3exports.gives = nest('message.sync.timestamp', true)
4
5// get the asserted timestamp for a given message unless the message was
6// received before the claimed time, then use recieve time
7// (handles clocks set into the future, and avoid received "3 mins from now" issue!)
8
9exports.create = function (api) {
10 return nest('message.sync.timestamp', function (msg) {
11 if (!msg || !msg.value || !msg.value.timestamp) return
12 if (msg.timestamp) {
13 return Math.min(msg.timestamp, msg.value.timestamp)
14 } else {
15 return msg.value.timestamp
16 }
17 })
18}
19

Built with git-ssb-web