git ssb

1+

Dominic / secure-scuttlebutt



Commit 38ef1409d7b796b658aaae45e4c9c1c6554b91da

we need to know immedately when a message is received, for replication

Dominic Tarr committed on 4/8/2017, 12:12:34 AM
Parent: ee8d1567d50d2cff08efbfe027b99107a276acb4

Files changed

index.jschanged
index.jsView
@@ -2,8 +2,9 @@
22
33 var join = require('path').join
44 var assert = require('assert')
55 var EventEmitter = require('events')
6 +var Obv = require('obv')
67
78 var contpara = require('cont').para
89 var pull = require('pull-stream')
910 var pl = require('pull-level')
@@ -71,16 +72,21 @@
7172 db.__proto__ = new EventEmitter()
7273
7374 db.opts = opts
7475
76 + db.post = Obv()
7577 db.batch = function (batch, cb) {
7678 db.append(batch.map(function (e) {
7779 return {
7880 key: e.key,
7981 value: e.value,
8082 timestamp: timestamp()
8183 }
8284 }), function (err, offsets) {
85 + batch.forEach(function (msg, i) {
86 + //trigger post immediately.
87 + db.post.set(msg)
88 + })
8389 cb(err)
8490 })
8591 }
8692
@@ -100,9 +106,15 @@
100106 // else cb(null, seq)
101107 else _get(key, cb) //seq
102108 }
103109
104- db.add = Validator(db, opts)
110 + var add = Validator(db, opts)
111 + db.add = function (msg, cb) {
112 + add(msg, function (err, value) {
113 + if(err) console.log(err)
114 + cb(err, value)
115 + })
116 + }
105117
106118 var realtime = Notify()
107119
108120 //TODO: eventually, this should filter out authors you do not follow.
@@ -220,4 +232,5 @@
220232
221233 return db
222234 }
223235
236 +

Built with git-ssb-web