Commit a7051e65b56caff3ad3d3a29c4bf59526525e225
remove unused code
Dominic Tarr committed on 9/22/2017, 9:03:25 PMParent: 5c49f6009ad5b21074c77817ed53d140a4b0f9b6
Files changed
example.js | changed |
_async.js | deleted |
async.js | deleted |
dump.js | deleted |
example.js | |||
---|---|---|---|
@@ -22,9 +22,9 @@ | |||
22 | 22 … | return false | |
23 | 23 … | } | |
24 | 24 … | state.queue.shift() | |
25 | 25 … | var s = ((Date.now() - start)/1000) | |
26 | - if(!(c++%100)) { | ||
26 … | + if(!(c++%1000)) { | ||
27 | 27 … | console.log(s, e, c, c / s) | |
28 | 28 … | } | |
29 | 29 … | return true | |
30 | 30 … | }, sbot.close) |
_async.js | ||
---|---|---|
@@ -1,66 +1,0 @@ | ||
1 | -var Obv = require('obv') | |
2 | -var V = require('./') | |
3 | - | |
4 | -module.exports = function (state, log) { | |
5 | - | |
6 | - var writing = Obv() | |
7 | - writing.set(false) | |
8 | - var author | |
9 | - function queue (msg) { | |
10 | - state = V.queue(state, msg) | |
11 | - if(author && (msg.author !== author) && (state.feeds[author].queue.length > 20)) { | |
12 | - state = V.validate(state, author) | |
13 | - state = V.queue(state, msg) | |
14 | - } | |
15 | - else | |
16 | - state = V.queue(state, msg) | |
17 | - author = msg.author | |
18 | - } | |
19 | - | |
20 | - function flush (id, cb) { | |
21 | - if(!cb) | |
22 | - cb = id, id = null | |
23 | - | |
24 | - if(writing.value) | |
25 | - return writing.once(function () { flush(id, cb) }, false) | |
26 | - else | |
27 | - writing.set(true) | |
28 | - | |
29 | - if(id === true) { //flush everything | |
30 | - for(var k in state.feeds) | |
31 | - if(state.feeds[k].queue.length) | |
32 | - state = V.validate(state, k) | |
33 | - } | |
34 | - else if(id) | |
35 | - state = V.validate(state, id) | |
36 | - | |
37 | - if(state.queue.length) { | |
38 | - state.writing = state.queue | |
39 | - state.queue = [] | |
40 | - log.append(state.writing, function (err, value) { | |
41 | - state.writing = [] | |
42 | - writing.set(false) | |
43 | - cb(err, value) | |
44 | - }) | |
45 | - } | |
46 | - else | |
47 | - cb() | |
48 | - } | |
49 | - | |
50 | - return { | |
51 | - writing: writing, | |
52 | - append: function (msg, cb) { | |
53 | - queue(msg) | |
54 | - flush(msg.author, cb) | |
55 | - }, | |
56 | - queue: queue, | |
57 | - flush: flush, | |
58 | - validated: function () { | |
59 | - return state.validated | |
60 | - }, | |
61 | - queued: function () { | |
62 | - return state.queued | |
63 | - } | |
64 | - } | |
65 | -} | |
66 | - |
async.js | ||
---|---|---|
@@ -1,31 +1,0 @@ | ||
1 | -var V = require('./') | |
2 | -var AsyncWrite = require('async-write') | |
3 | - | |
4 | -module.exports = function (state, log, hmac_key) { | |
5 | - var queue = AsyncWrite(function (_, cb) { | |
6 | - var batch = state.queue | |
7 | - state.queue = [] | |
8 | - log.append(batch, cb) | |
9 | - }, function reduce(_, msg) { | |
10 | - return V.append(state, msg) | |
11 | - }, function (_state) { | |
12 | - return state.queue.length < 1000 | |
13 | - }, 200) | |
14 | - | |
15 | - return { | |
16 | - add: queue, | |
17 | - createFeed: function (keys) { | |
18 | - function add (msg, cb) { | |
19 | - queue( | |
20 | - V.create(state, hmac_key, keys, content, timestamp()), | |
21 | - cb | |
22 | - ) | |
23 | - } | |
24 | - return { | |
25 | - add: add, publish: add, | |
26 | - keys: keys, id: keys.id | |
27 | - } | |
28 | - } | |
29 | - } | |
30 | -} | |
31 | - |
dump.js | ||
---|---|---|
@@ -1,76 +1,0 @@ | ||
1 | -var validate = require('./') | |
2 | -var pull = require('pull-stream') | |
3 | -var state = validate.initial() | |
4 | - | |
5 | -var Log = require('flumelog-offset') | |
6 | - | |
7 | -var logfile = '/tmp/ssb-validate_dump-test' | |
8 | -try { require('fs').unlinkSync(logfile) } catch (_) {} | |
9 | - | |
10 | -var log = Log(logfile, 1024, require('flumecodec/json')) | |
11 | - | |
12 | -var async = require('./async')(state, log) | |
13 | - | |
14 | -require('ssb-client')(function (err, sbot) { | |
15 | - var c = 0, _c = 0, e = 0, d = 0, q = 0, v = 0, ts = Date.now(), start = Date.now() | |
16 | - | |
17 | - console.log('c, _c, d, e, q, v, c/s, mb, mb/s, s') | |
18 | - | |
19 | - function ConsoleLog () { | |
20 | - var s = (ts - start)/1000 | |
21 | - var mb = log.since.value / (1024*1024) | |
22 | - console.log(c, c - _c, d, e, q, v, c / s, mb, mb/s, s) | |
23 | - _c = c | |
24 | - d = 0 | |
25 | - | |
26 | - } | |
27 | - | |
28 | - function maybeLog () { | |
29 | - if(Date.now() > ts + 1000) { | |
30 | - ConsoleLog() | |
31 | - ts = Date.now() | |
32 | - } | |
33 | - } | |
34 | - | |
35 | - var author = null | |
36 | - | |
37 | - pull( | |
38 | - sbot.createLogStream({}), | |
39 | - function (read) { | |
40 | - return function (abort, cb) { | |
41 | - read(abort, function next (err, data) { | |
42 | - q = async.queued() | |
43 | - v = async.validated() | |
44 | - c = q + v | |
45 | - if(err) { | |
46 | - ConsoleLog() | |
47 | - return async.flush(true, function (_) { | |
48 | - q = async.queued() | |
49 | - v = async.validated() | |
50 | - c = q + v | |
51 | - ConsoleLog() | |
52 | - cb(err) | |
53 | - }) | |
54 | - } | |
55 | - maybeLog() | |
56 | - async.queue(data.value) | |
57 | - if(state.queue.length > 100) { | |
58 | - async.flush(null, function (err, data) { | |
59 | - maybeLog() | |
60 | - cb(err, data) | |
61 | - }) | |
62 | - } | |
63 | - else | |
64 | - read(null, next) | |
65 | - }) | |
66 | - } | |
67 | - }, | |
68 | - pull.drain(null, function () { | |
69 | - sbot.close() | |
70 | - }) | |
71 | - ) | |
72 | -}) | |
73 | - | |
74 | - | |
75 | - | |
76 | - |
Built with git-ssb-web