forked from byteball/obyte-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relay.js
30 lines (26 loc) · 798 Bytes
/
relay.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
/*jslint node: true */
"use strict";
var conf = require('ocore/conf.js');
var myWitnesses = require('ocore/my_witnesses.js');
function replaceConsoleLog () {
var clog = console.log;
console.log = function () {
Array.prototype.unshift.call(arguments, new Date().toISOString() + ':');
clog.apply(null, arguments);
}
}
function start () {
console.log('starting');
var network = require('ocore/network.js');
if (conf.initial_peers)
conf.initial_peers.forEach(function (url) {
network.findOutboundPeerOrConnect(url);
});
}
replaceConsoleLog();
myWitnesses.readMyWitnesses(function (arrWitnesses) {
if (arrWitnesses.length > 0)
return start();
console.log('will init witnesses', conf.initial_witnesses);
myWitnesses.insertWitnesses(conf.initial_witnesses, start);
}, 'ignore');