try this
This commit is contained in:
parent
c5875332d4
commit
fae38b1ee8
@ -259,45 +259,50 @@ ProcessSerial.prototype._transform = function(block, enc, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.whilst(
|
||||
function() {
|
||||
return self.db.concurrentTip.__height < block.__height || self.db.tip.__height < block.__height - 1;
|
||||
},
|
||||
function(next) {
|
||||
var nextCalled = false;
|
||||
// wait until concurrent handler is ahead of us
|
||||
self.db.once('addblock', function() {
|
||||
if(!nextCalled) {
|
||||
next();
|
||||
}
|
||||
nextCalled = true;
|
||||
});
|
||||
self.db.once('concurrentaddblock', function() {
|
||||
if(!nextCalled) {
|
||||
next();
|
||||
}
|
||||
nextCalled = true;
|
||||
});
|
||||
},
|
||||
function() {
|
||||
self.db.getSerialBlockOperations(block, true, function(err, operations) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
if(check) {
|
||||
return self._process(block, callback);
|
||||
}
|
||||
|
||||
operations.push(self.db.getTipOperation(block, true));
|
||||
var processed = false;
|
||||
|
||||
var obj = {
|
||||
tip: block,
|
||||
operations: operations
|
||||
};
|
||||
|
||||
self.tip = block;
|
||||
|
||||
callback(null, obj);
|
||||
});
|
||||
self.db.on('addblock', function() {
|
||||
if(!processed) {
|
||||
processed = true;
|
||||
return self._process(block, callback);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
self.db.on('concurrentblock', function() {
|
||||
if(!processed) {
|
||||
processed = true;
|
||||
return self._process(block, callback);
|
||||
}
|
||||
});
|
||||
|
||||
function check() {
|
||||
return self.db.concurrentTip.__height < block.__height || self.db.tip.__height < block.__height - 1;
|
||||
}
|
||||
};
|
||||
|
||||
ProcessSerial.prototype._process = function(block, callback) {
|
||||
var self = this;
|
||||
|
||||
self.db.getSerialBlockOperations(block, true, function(err, operations) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
operations.push(self.db.getTipOperation(block, true));
|
||||
|
||||
var obj = {
|
||||
tip: block,
|
||||
operations: operations
|
||||
};
|
||||
|
||||
self.tip = block;
|
||||
|
||||
callback(null, obj);
|
||||
});
|
||||
};
|
||||
|
||||
function ProcessConcurrent(highWaterMark, db) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user