Commit f646bdf3 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fix: during proof-of-work, a maximum call stack size exceeded error could occur

parent 31998bfc
...@@ -1182,21 +1182,26 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) { ...@@ -1182,21 +1182,26 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
block.date = newTS; block.date = newTS;
} }
raw = block.getRaw(); raw = block.getRaw();
sigFunc(raw, function (err, sigResult) { async.waterfall([
sig = dos2unix(sigResult); function (next){
var full = raw + sig + '\n'; sigFunc(raw, next);
pow = full.hash(); },
testsCount++; function (sigResult, next){
if (testsCount % 100 == 0) { sig = dos2unix(sigResult);
process.stdout.write('.'); var full = raw + sig + '\n';
} else if (testsCount % 50 == 0) { pow = full.hash();
if (newKeyblockCallback) { testsCount++;
computationActivated = false if (testsCount % 100 == 0) {
next('New block received'); process.stdout.write('.');
} else if (testsCount % 50 == 0) {
if (newKeyblockCallback) {
computationActivated = false
next('New block received');
}
} }
} next();
next(); },
}); ], next);
}, function (err) { }, function (err) {
if (err) { if (err) {
logger.debug('Proof-of-work computation canceled: valid block received'); logger.debug('Proof-of-work computation canceled: valid block received');
......
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