Commit ec9bfbd5c334144796063edc61e8e12ac90011ae
use minimum value of asserted/received for asserted timestamp
messages can’t be written before they were received! stops the case where incorrectly set clocks cause messages to get stuck at top of feedMatt McKegg committed on 12/12/2017, 1:55:44 AM
Parent: 802a60339e1acf7a9475055d8ad7c94155f24c36
Files changed
emit-links.js | changed |
index.js | changed |
emit-links.js | ||
---|---|---|
@@ -21,8 +21,9 @@ | ||
21 | 21 … | } |
22 | 22 … | }) |
23 | 23 … | links.forEach(link => { |
24 | 24 … | emit(extend(msg, { |
25 … | + rts: resolveTimestamp(msg), | |
25 | 26 … | dest: link |
26 | 27 … | })) |
27 | 28 … | }) |
28 | 29 … | } |
@@ -30,8 +31,17 @@ | ||
30 | 31 … | function isChannel (value) { |
31 | 32 … | return typeof value === 'string' && value.length < 30 && matchChannel.test(value) |
32 | 33 … | } |
33 | 34 … | |
35 … | +function resolveTimestamp (msg) { | |
36 … | + if (!msg || !msg.value || !msg.value.timestamp) return | |
37 … | + if (msg.timestamp) { | |
38 … | + return Math.min(msg.timestamp, msg.value.timestamp) | |
39 … | + } else { | |
40 … | + return msg.value.timestamp | |
41 … | + } | |
42 … | +} | |
43 … | + | |
34 | 44 … | function walk (obj, fn, prefix) { |
35 | 45 … | if (obj && typeof obj === 'object') { |
36 | 46 … | for (var k in obj) { |
37 | 47 … | walk(obj[k], fn, (prefix || []).concat(k)) |
index.js | ||
---|---|---|
@@ -4,13 +4,13 @@ | ||
4 | 4 … | var emitLinks = require('./emit-links') |
5 | 5 … | |
6 | 6 … | var indexes = [ |
7 | 7 … | { key: 'DTS', value: [['dest'], ['timestamp']] }, |
8 | - { key: 'DTA', value: [['dest'], ['value', 'timestamp']] }, // asserted timestamp | |
9 | - { key: 'TDT', value: [['value', 'content', 'type'], ['dest'], ['value', 'timestamp']] } | |
8 … | + { key: 'DTA', value: [['dest'], ['rts']] }, // asserted timestamp | |
9 … | + { key: 'TDT', value: [['value', 'content', 'type'], ['dest'], ['rts']] } | |
10 | 10 … | ] |
11 | 11 … | |
12 | -var indexVersion = 5 | |
12 … | +var indexVersion = 6 | |
13 | 13 … | |
14 | 14 … | exports.name = 'backlinks' |
15 | 15 … | exports.version = require('./package.json').version |
16 | 16 … | exports.manifest = { |
Built with git-ssb-web