Commit f1181ae2 authored by Cédric Moreau's avatar Cédric Moreau

Enabling network PoW finding

parent cec89073
......@@ -34,6 +34,17 @@ function Multicaster () {
});
});
that.on('keyblock', function(keyblock, peers) {
logger.debug('--> new Keyblock to be sent to %s peer(s)', peers.length);
peers.forEach(function(peer){
fifo.push(function (sent) {
sendKeyblock(peer, keyblock, success(function (err) {
sent();
}));
});
});
});
that.on('transaction', function(transaction, peers) {
logger.debug('--> new Transaction to be sent to %s peer(s)', peers.length);
peers.forEach(function(peer){
......
......@@ -24,6 +24,7 @@ function Router (serverFPR, conn) {
this._write = function (obj, enc, done) {
if (typeof obj.email != 'undefined') { route('pubkey', obj, getRandomInUPPeers, done); }
else if (obj.keysChanges ? true : false) { route('keyblock', obj, getRandomInUPPeers, done); }
else if (obj.recipient ? true : false) { route('transaction', obj, getTargetedButSelf(obj.recipient), done); }
else if (obj.endpoints ? true : false) { route('peer', obj, getRandomInAllPeersButPeer(obj.fingerprint), done); }
else if (obj.forward ? true : false) { route('forward', obj, getTargetedButSelf(obj.to), done); }
......
......@@ -409,9 +409,9 @@ program
.description('Start uCoin server using given --currency')
.action(service(LISTEN_HTTP, ucoin.createPeerServer, function (server, conf) {
// server
// .pipe(router(server.PeeringService.cert.fingerprint, server.conn))
// .pipe(multicaster());
server
.pipe(router(server.PeeringService.cert.fingerprint, server.conn))
.pipe(multicaster());
// Launching server
server.on('BMALoaded', function (err, app) {
......
......@@ -34,10 +34,7 @@ function Server (dbConf, overrideConf, interceptors, onInit) {
that.emit('services', err);
done(err);
});
}
];
var todoOnInit = initFunctions.concat(onInit).concat([
},
function (done) {
if (dbConf.listenBMA) {
listenBMA(function (err, app) {
......@@ -46,6 +43,9 @@ function Server (dbConf, overrideConf, interceptors, onInit) {
});
} else done();
}
];
var todoOnInit = initFunctions.concat(onInit).concat([
]);
this._write = function (obj, enc, writeDone, isInnerWrite) {
......
......@@ -34,9 +34,9 @@ function WOTServer (dbConf, overrideConf, interceptors, onInit) {
function (next){
server.KeychainService.submitKeyBlock(obj, next);
},
function (tx, next){
server.emit('keyblock', tx);
next(null, tx);
function (kb, next){
server.emit('keyblock', kb);
next(null, kb);
},
], next);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment