git ssb

0+

Dominic / ssb-ooo



Commit 6fbec0a38fef8d02dc7b8d5a39736c7a2d23470c

filter out requests that are not valid

Dominic Tarr committed on 11/12/2017, 9:42:51 PM
Parent: 9268b78bc5cd805a89d0c37d82c87f25b03e1a09

Files changed

index.jschanged
index.jsView
@@ -1,8 +1,8 @@
11 var pull = require('pull-stream')
22 var GQ = require('gossip-query')
33 var hash = require('ssb-keys/util').hash
4-
4 +var ref = require('ssb-ref')
55 function getId(msg) {
66 return '%'+hash(JSON.stringify(msg, null, 2))
77 }
88
@@ -35,8 +35,15 @@
3535
3636 store = Store(config)
3737
3838 var gq = GQ({
39 + isQuery: ref.isMsg,
40 + isRequest: function (n) {
41 + return Number.isInteger(n) && n < 0
42 + },
43 + isResponse: function (o) {
44 + return o && isObject(o)
45 + },
3946 check: function (key, cb) {
4047 store.keys.get(key, function (err, data) {
4148 if(data) cb(null, data.value)
4249 else
@@ -83,8 +90,15 @@
8390 status.ooo[id] = gq.state[id]
8491 return status
8592 })
8693
94 + sbot.progress.hook(function (fn, args) {
95 + var prog = fn()
96 + prog.ooo = gq.progress()
97 + return prog
98 + })
99 +
100 +
87101 sbot.on('rpc:connect', function (rpc, isClient) {
88102 if(isClient) {
89103 var stream = gq.createStream(rpc.id)
90104 pull(stream, rpc.ooo.stream(function () {}), stream)

Built with git-ssb-web