git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 0b68762e851dab73abc45fa60add0d96d3b5c7ac

Files: 0b68762e851dab73abc45fa60add0d96d3b5c7ac / 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