Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sbot.identities.list(function (err, ls) {
if(err) throw err
cont.para(
ls.map(function (id) {
return function (cb) {
sbot.identities.publishAs({id: id, content: {type:'post', text: 'hello'}}, cb)
}
})
)(function (err, ary) {
if(err) throw err
console.log(ary)
ary.forEach(function (e, i) {
t.equal(e.value.author, ls[i])
})
t.end()
})
})
})
if(!recv[n][k]) missing ++
else has ++
}
}
console.log('missing/has' ,missing, has)
if(!missing)
console.log('CONSISTENT!!!')
}
}
a_bot.post(consistent('alice'))
b_bot.post(consistent('bob'))
c_bot.post(consistent('charles'))
cont.para(feeds.map(function (f) {
return function (cb) {
return f.publish({type:'post', text: 'hello world'}, cb)
}
}))(function () {
function log (name) {
return pull.through(function (data) {
console.log(name, data)
})
}
function peers (a, b, name1, name2, d) {
var a_rep = a.ebt.replicate.call({id: name2}, {version: 2})
var b_rep = b.ebt.replicate.call({id: name1}, {version: 2})
pull(
pull(
a_rep,
Delay(d),
log(name1+'->'+name2),
b_rep,
Delay(d),
log(name2+'->'+name1),
a_rep
)
}
a_bot.post(consistent('alice'))
b_bot.post(consistent('bob'))
cont.para(feeds.map(function (f) {
return f.publish({type:'post', text: 'hello world'})
}))(function () {
peers(a_bot, b_bot, 'a', 'b', 10)
})
var i = N
var int = setInterval(function () {
var feed = feeds[~~(rng.random()*feeds.length)]
feed.publish({type:'post', text: i.toString()}, function () {})
if(--i) return
clearInterval(int)
console.log('Alice', a_bot.since())
console.log('Bob', b_bot.since())
function isAnyOurMessage (msg, ids, cb) {
cont.para(ids.map(function (id) {
return function (cb) { isOurMsg(id, cb) }
}))(function (err, results) {
if (err) cb(err)
else if (results.some(Boolean)) cb(null, msg)
else cb()
})
}
function isAnyOurMessage(msg, ids, cb) {
cont.para(ids.map(function (id) {
return function (cb) { isOurMsg(id, cb) }
}))
(function (err, results) {
if (err) cb(err)
else if (results.some(Boolean)) cb(null, msg)
else cb()
})
}
rebuild: function (cb) {
throwIfClosed('rebuild')
return cont.para(map(flume.views, function (sv) {
return function (cb) {
//destroying will stop createSink stream
//and flumedb will restart write.
sv.destroy(function (err) {
if(err) return cb(err)
//when the view is up to date with log again
//callback, but only once, and then stop observing.
//(note, rare race condition where sv might already be set,
//so called before rm is returned)
var rm = sv.since(function (v) {
if(v === log.since.value) {
var _cb = cb; cb = null; _cb()
}
if(!cb && rm) rm()
})
})