-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo1_hello_bloc.js
43 lines (32 loc) · 964 Bytes
/
demo1_hello_bloc.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
#!/usr/bin/env node
"use strict";
const co = require('co');
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
***************************************/
const head = yield duniterServer.dal.blockDAL.getCurrent();
if (head) {
console.log('Bloc courant = #%s', head.number);
} else {
console.log('Pas de bloc courant, blockchain vide.');
}
process.exit(0);
/****************************************/
} catch (e) {
console.error(e);
process.exit(1);
}
}));