git ssb

4+

Dominic / scuttlebot



Commit 617f906272a087ee445056d1b722241f1728275c

Merge branch 'ssb_minimal' of ../_scuttlebot

Dominic Tarr committed on 10/29/2017, 6:47:04 AM
Parent: 34a334f786f16f1ad957c4c2981f04a5fb8038ce
Parent: 94202451dc4011befeceade810fdf8a1895f768f

Files changed

index.jschanged
plugins/invite.jschanged
test/caps.jschanged
test/random.jschanged
test/realtime.jschanged
index.jsView
@@ -102,8 +102,9 @@
102102 close : valid.async(close),
103103
104104 publish : valid.async(feed.add, 'string|msgContent'),
105105 add : valid.async(ssb.add, 'msg'),
106 + queue : valid.async(ssb.queue, 'msg'),
106107 get : valid.async(ssb.get, 'msgId|number'),
107108
108109 post : ssb.post,
109110
@@ -160,4 +161,5 @@
160161 //when creating a Sbot instance.
161162 appKey: require('./lib/ssb-cap')
162163 })
163164 .use(SSB)
165 +
plugins/invite.jsView
@@ -183,13 +183,36 @@
183183 }
184184
185185 opts = ref.parseAddress(ref.parseInvite(invite).remote)
186186
187- ssbClient(null, {
188- caps: config.caps,
189- remote: invite,
190- manifest: {invite: {use: 'async'}, getAddress: 'async'}
191- }, function (err, rpc) {
187 + function connect (cb) {
188 + ssbClient(null, {
189 + caps: config.caps,
190 + remote: invite,
191 + manifest: {invite: {use: 'async'}, getAddress: 'async'}
192 + }, cb)
193 + }
194 +
195 + // retry 3 times, with timeouts.
196 + // This is an UGLY hack to get the test/invite.js to pass
197 + // it's a race condition, I think because the server isn't ready
198 + // when it connects?
199 +
200 + function retry (fn, cb) {
201 + var n = 0
202 + ;(function next () {
203 + var start = Date.now()
204 + fn(function (err, value) {
205 + n++
206 + if(n >= 3) cb(err, value)
207 + else if(err) setTimeout(next, 500 + (Date.now()-start)*n)
208 + else cb(null, value)
209 + })
210 + })()
211 + }
212 +
213 + retry(connect, function (err, rpc) {
214 +
192215 if(err) return cb(explain(err, 'could not connect to server'))
193216
194217 // command the peer to follow me
195218 rpc.invite.use({ feed: server.id }, function (err, msg) {
test/caps.jsView
@@ -63,13 +63,13 @@
6363 tape('signatures not accepted if made from different caps', function (t) {
6464
6565
6666 dbA.publish({type: 'test', foo: true}, function (err, msg) {
67-
67 + if(err) throw err
6868 console.log(msg)
6969 dbB.add(msg.value, function (err) {
7070 t.ok(err) //should not be valid in this universe
71- t.ok(/signature was invalid/.test(err.message))
71 + t.ok(/invalid signature/.test(err.message))
7272 console.log(err.stack)
7373 t.end()
7474
7575 })
test/random.jsView
@@ -11,9 +11,8 @@
1111 var dogs = require('dog-names')
1212
1313 var generated = {}, F=100,N=10000
1414
15-
1615 //build a random network, with n members.
1716 function bar (prog) {
1817 var r = prog.progress/prog.total
1918 var s = '\r', M = 50
@@ -190,9 +189,10 @@
190189
191190 pull(
192191 dump.createLogStream({live: true, keys: false}),
193192 pull.drain(function (e) {
194- live ++
193 + if(!(live ++ % 100))
194 + console.log('live', live)
195195 })
196196 )
197197
198198 var wants = {}, n = 0, c = 0, start = Date.now()
test/realtime.jsView
@@ -44,11 +44,10 @@
4444 ary.push(data);
4545 })
4646 )
4747 var l = 12
48- var int = setInterval(function () {
48 + setTimeout(function next () {
4949 if(!--l) {
50- clearInterval(int)
5150 var _ary = []
5251 pull(
5352 bob.createHistoryStream({id: alice.id, sequence: 0, keys: false}),
5453 pull.collect(function (err, _ary) {
@@ -62,11 +61,11 @@
6261 alice.publish({type: 'test', value: new Date()},
6362 function (err, msg){
6463 if(err) throw err
6564 console.log('added', msg.key, msg.value.sequence)
65 + setTimeout(next, 200)
6666 })
6767 }, 200)
6868
6969 })
7070 })
7171
72-

Built with git-ssb-web