Commit 3627ef5bb2d0af90d48c88e2897c15df3cd2dd11
add cache to mySeq checker
mix irving committed on 5/31/2018, 11:35:30 AMParent: 5f86bdb837a971c779cc9be81fd7c8e39090a252
Files changed
ftu/manageProgress.js | changed |
ftu/manageProgress.js | ||
---|---|---|
@@ -24,9 +24,9 @@ | ||
24 | 24 | // ) |
25 | 25 | |
26 | 26 | // watch progress (db size) ?? |
27 | 27 | // sbot.progress(console.log) |
28 | - // | |
28 | + | |
29 | 29 | sbot.gossip.peers((err, peers) => { |
30 | 30 | if (err) return console.error(err) |
31 | 31 | |
32 | 32 | connectToPeers({ sbot, peers, state }) |
@@ -66,13 +66,15 @@ | ||
66 | 66 | if (importComplete) sink.abort(() => console.log('stopping watchCurrentSequence')) |
67 | 67 | }) |
68 | 68 | } |
69 | 69 | |
70 | +var cache = {} | |
70 | 71 | function watchLatestSequence ({ sbot, period, state }) { |
71 | 72 | const feedId = sbot.id |
72 | 73 | sbot.ebt.peerStatus(feedId, (err, data) => { |
73 | 74 | if (err) return setTimeout(() => watchLatestSequence({ sbot, period, state }), period) |
74 | 75 | |
76 | + cache = data = Object.assign({}, cache, data) | |
75 | 77 | const currentLatest = resolve(state.mySequence.latest) |
76 | 78 | |
77 | 79 | const remoteSeqs = map(data.peers, (val) => val.seq) |
78 | 80 | .filter(s => s >= currentLatest) // only keep remote seq that confirm or update backup seq |
Built with git-ssb-web