-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo2_sql.js
46 lines (35 loc) · 1.11 KB
/
demo2_sql.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
#!/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
***************************************/
console.log('Recherche des pairs connus en base de données...');
const peers = yield duniterServer.dal.peerDAL.query('SELECT * FROM peer');
if (peers.length == 0) {
console.log('Aucun pair trouvé en base de données.');
} else {
for (const pair of peers) {
console.log('Pair : %s, interface : %s', pair.pubkey, pair.endpoints[0]);
}
}
process.exit(0);
/****************************************/
} catch (e) {
console.error(e);
process.exit(1);
}
}));