-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo3_flux.js
49 lines (38 loc) · 1.09 KB
/
demo3_flux.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
"use strict";
const co = require('co');
const es = require('event-stream');
const duniter = require('duniter');
const HOME_DUNITER_DATA_FOLDER = 'rml8';
// Use netobs data folder
if (!process.argv.includes('--mdb')) {
process.argv.push('--mdb');
process.argv.push(HOME_DUNITER_DATA_FOLDER);
}
// Default action = start
if (process.argv.length === 4) process.argv.push('start');
// Disable Duniter logs
duniter.statics.logger.mute();
duniter.statics.cli((duniterServer) => co(function*() {
try {
/****************************************
* SPECIALISATION
***************************************/
duniterServer.pipe(es.mapSync((data) => {
if (data.documentType == 'peer') {
console.log('>> Nouvelle fiche de pair !');
}
else if (data.documentType == 'block') {
console.log('>> Nouveau bloc !');
}
else {
console.log('>> Nouvelle donnée !');
console.log(data);
}
}));
/****************************************/
} catch (e) {
console.error(e);
process.exit(1);
}
}));