sync first attempt
This commit is contained in:
parent
fc8f53372a
commit
f2fccdd14f
@ -206,9 +206,27 @@ BlockService.prototype.getLatest = function() {
|
||||
|
||||
return self.getBlock(blockHash);
|
||||
|
||||
}).catch(blockNotFound);
|
||||
}).catch(function(err) {
|
||||
if (err instanceof LevelUp.errors.NotFoundError) {
|
||||
return null;
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Save a new block
|
||||
*
|
||||
* @param {bitcore.Block} block
|
||||
* @return {Promise<Block>} a promise of the same block, for chaining
|
||||
*/
|
||||
BlockService.prototype.save = function(block) {
|
||||
// TODO: unconfirm previous tip, confirm new tip.
|
||||
return this._confirmBlock(block);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set a block as the current tip of the blockchain
|
||||
*
|
||||
@ -250,11 +268,9 @@ BlockService.prototype._confirmBlock = function(block) {
|
||||
|
||||
}).then(function() {
|
||||
|
||||
return self.database.batchAsync(ops)
|
||||
return self.database.batchAsync(ops);
|
||||
|
||||
}).then(function() {
|
||||
return self.unlock();
|
||||
});
|
||||
}).then(this.unlock.bind(this));
|
||||
};
|
||||
|
||||
BlockService.prototype._setNextBlock = function(ops, prevBlockHash, block) {
|
||||
|
||||
@ -60,7 +60,8 @@
|
||||
"glob": "*",
|
||||
"js-yaml": "^3.2.7",
|
||||
"level-lock": "^1.0.1",
|
||||
"levelup": "~0.19.0",
|
||||
"leveldown": "^1.0.0",
|
||||
"levelup": "^0.19.0",
|
||||
"moment": "~2.5.0",
|
||||
"morgan": "^1.5.1",
|
||||
"request": "^2.48.0",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user