git ssb

4+

Dominic / scuttlebot



Commit 6e33f07845645357ffa0cc0627d468370589424b

get most important plugins working

Dominic Tarr committed on 12/10/2016, 5:24:41 PM
Parent: 2f4909ea8e4b5eadece02b7fa5eefa11a02a83b1

Files changed

plugins/friends.jschanged
plugins/invite.jschanged
plugins/replicate.jschanged
plugins/friends.jsView
@@ -33,9 +33,10 @@
3333 var g = null
3434
3535 var index = sbot._flumeUse('friends', Reduce(1, function (g, rel) {
3636 if(!g) g = {}
37- G.addEdge(g, rel.from, rel.to, rel.value)
37 +
38 + G.addEdge(g, rel.from, rel.to, rel.value)
3839 return g
3940 }, function (data) {
4041 if(data.value.content.type === 'contact' && ref.isFeed(data.value.content.contact))
4142 return {
@@ -47,22 +48,22 @@
4748
4849 return {
4950
5051 get: function (opts, cb) {
51- console.log('friends.get', opts, cb)
5252 index.get(null, cb || opts)
5353 },
5454
5555 createFriendStream: valid.source(function (opts) {
5656 opts = opts || {}
5757 var start = opts.start || sbot.id
58- var reachable = {}, g = {}
58 + var reachable
5959 return pull(
6060 index.stream(opts),
6161 FlatMap(function (v) {
6262 var out = []
6363 if(!v) return []
6464 if(v.from && v.to) {
65 + G.addEdge(g, v.from, v.to, v.value)
6566 var _reachable = G.hops(g, start, 0, opts.hops || 3, reachable)
6667 for(var k in _reachable) {
6768 if(reachable[k] == null)
6869 out.push({id: k, hops: reachable[k] = _reachable[k]})
@@ -84,20 +85,14 @@
8485 }, 'createFriendStreamOpts?'),
8586
8687 hops: function (opts, cb) {
8788 opts = opts || {}
89 + if(isString(opts))
90 + opts = {start: opts}
8891 index.get(null, function (err, g) {
8992 if(err) cb(err)
9093 else cb(null, G.hops(g, opts.start || sbot.id, 0, opts.hops || 3))
9194 })
9295 }
9396 }
9497 }
9598
96-
97-
98-
99-
100-
101-
102-
103-
plugins/invite.jsView
@@ -108,9 +108,11 @@
108108 codesDB.get(rpc.id, function(err, invite) {
109109 if(err) return cb(err)
110110
111111 // check if we're already following them
112- server.friends.all('follow', function(err, follows) {
112 + server.friends.get(function (err, follows) {
113 +// server.friends.all('follow', function(err, follows) {
114 +// if(hops[req.feed] == 1)
113115 if (follows && follows[server.id] && follows[server.id][req.feed])
114116 return cb(new Error('already following'))
115117
116118 // although we already know the current feed
plugins/replicate.jsView
@@ -115,10 +115,13 @@
115115 function localPeers () {
116116 if(!sbot.gossip) return
117117 sbot.gossip.peers()
118118 .forEach(function (e) {
119- if(to_send[e.key] == null)
120- addPeer({id: e.key, sequence: 0})
119 + if(to_send[e.key] == null) {
120 + sbot.latestSequence(e.key, function (err, seq) {
121 + addPeer({id: e.key, sequence: seq})
122 + })
123 + }
121124 })
122125 }
123126
124127 //also request local peers.
@@ -154,10 +157,10 @@
154157 if(data.sync) return cb(null, S = data)
155158 var id = data.id || data
156159 sbot.latestSequence(id, function (err, seq) {
157160 cb(null, {
158- id: id, sequence: err ? 0 : toSeq(seq)
159- })
161 + id: id, sequence: err ? 0 : toSeq(seq)
162 + })
160163 })
161164 }, 32),
162165 pull.drain(addPeer)
163166 )
@@ -192,14 +195,14 @@
192195 debounce.set()
193196 pull(
194197 rpc.createHistoryStream({
195198 id: upto.id,
196- seq: (upto.sequence || upto.seq || 0) + 1,
199 + sequence: (upto.sequence || upto.seq || 0) + 1,
197200 live: true,
198201 keys: false
199202 }),
200203 sbot.createWriteStream(function (err) {
201- if(err) console.error(err.stack)
204 + if(err) console.error(err.message)
202205
203206 feeds--
204207 debounce.set()
205208 })
@@ -221,13 +224,4 @@
221224
222225
223226
224227
225-
226-
227-
228-
229-
230-
231-
232-
233-

Built with git-ssb-web