forked from byteball/obyte-relay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
29 lines (26 loc) · 799 Bytes
/
start.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
/*jslint node: true */
"use strict";
var conf = require('byteballcore/conf.js');
var myWitnesses = require('byteballcore/my_witnesses.js');
function replaceConsoleLog(){
var clog = console.log;
console.log = function(){
Array.prototype.unshift.call(arguments, Date().toString()+':');
clog.apply(null, arguments);
}
}
function start(){
console.log('starting');
var network = require('byteballcore/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');