git ssb

0+

Matt McKegg / ssb-backlinks



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 feed
Matt McKegg committed on 12/12/2017, 1:55:44 AM
Parent: 802a60339e1acf7a9475055d8ad7c94155f24c36

Files changed

emit-links.jschanged
index.jschanged
emit-links.jsView
@@ -21,8 +21,9 @@
2121 }
2222 })
2323 links.forEach(link => {
2424 emit(extend(msg, {
25 + rts: resolveTimestamp(msg),
2526 dest: link
2627 }))
2728 })
2829 }
@@ -30,8 +31,17 @@
3031 function isChannel (value) {
3132 return typeof value === 'string' && value.length < 30 && matchChannel.test(value)
3233 }
3334
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 +
3444 function walk (obj, fn, prefix) {
3545 if (obj && typeof obj === 'object') {
3646 for (var k in obj) {
3747 walk(obj[k], fn, (prefix || []).concat(k))
index.jsView
@@ -4,13 +4,13 @@
44 var emitLinks = require('./emit-links')
55
66 var indexes = [
77 { 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']] }
1010 ]
1111
12-var indexVersion = 5
12 +var indexVersion = 6
1313
1414 exports.name = 'backlinks'
1515 exports.version = require('./package.json').version
1616 exports.manifest = {

Built with git-ssb-web