git ssb

4+

Dominic / scuttlebot



Commit f3885cfda231da4263dec7ed80d25979cd50a76f

get block working correctly

Dominic Tarr committed on 5/31/2017, 11:49:21 AM
Parent: 4bbdcb0f89770891b04720e98b31f99295fe0d13

Files changed

plugins/block.jschanged
plugins/friends.jschanged
plugins/replicate/index.jschanged
plugins/block.jsView
@@ -29,11 +29,15 @@
2929 }
3030
3131 sbot.createHistoryStream.hook(function (fn, args) {
3232 var opts = args[0], id = this.id
33- if(opts.id !== this.id && isBlocked({source: opts.id, dest: this.id}))
34- return fn({id: null, sequence: 0})
35- else
33+ //reminder: this.id is the remote caller.
34+ if(opts.id !== this.id && isBlocked({source: opts.id, dest: id})) {
35+ return function (abort, cb) {
36+ //just give them the cold shoulder
37+ }
38+// return fn({id: null, sequence: 0})
39+ } else
3640 return pull(
3741 fn.apply(this, args),
3842 //break off this feed if they suddenly block
3943 //the recipient.
@@ -57,4 +61,5 @@
5761
5862 return {isBlocked: valid.sync(isBlocked, 'feedId|isBlockedOpts') }
5963
6064 }
65+
plugins/friends.jsView
@@ -93,11 +93,11 @@
9393 if(block.isWanted(reachable[k]))
9494 push(k, reachable[k][0])
9595 } else {
9696 var _reachable = F.reachable(g, start, block)
97- var patch = F.diff(reachable, _reachable)
97+ var patch = F.diff(reachable, _reachable, block)
9898 for(var k in patch) {
99- if(patch[k] == null)
99+ if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1])
100100 push(k, -1)
101101 else if(block.isWanted(patch[k]))
102102 push(k, patch[k][0])
103103 }
@@ -121,9 +121,4 @@
121121 })
122122 }
123123 }
124124 }
125-
126-
127-
128-
129-
plugins/replicate/index.jsView
@@ -24,15 +24,18 @@
2424 //to add things is easy, you just call replicate.request(id)
2525 //calls to replicate.request(id) are ephemeral,
2626 //and must be made each time run sbot.
2727 pull(
28- sbot.friends.createFriendStream({live: true, meta: false}),
28+ sbot.friends.createFriendStream({live: true, meta: true}),
2929 // filter out duplicates, and also keep track of what we expect to receive
3030 // lookup the latest sequence from each user
3131 // TODO: use paramap?
32- pull.drain(function (id) {
33- if(id.sync) return
34- replicate.request(id)
32+ pull.drain(function (data) {
33+ if(data.sync) return
34+ if(data.hops >= 0)
35+ replicate.request(data.id)
36+ else
37+ replicate.request(data.id, false)
3538 })
3639 )
3740
3841 return replicate
@@ -40,4 +43,5 @@
4043 }
4144 }
4245
4346
47+

Built with git-ssb-web