use async writes.

This commit is contained in:
Christopher Jeffrey 2016-01-21 14:10:01 -08:00
parent cb73ab908e
commit a459d190aa

View File

@ -816,6 +816,10 @@ ChainDB.prototype.cache = function cache(entry) {
};
ChainDB.prototype.get = function get(height) {
return this.getSync(height);
};
ChainDB.prototype.getSync = function getSync(height) {
var data, entry;
if (this._cache[height])
@ -889,6 +893,10 @@ ChainDB.prototype.getAsync = function getAsync(height, callback) {
};
ChainDB.prototype.save = function save(entry) {
return this.saveAsync(entry);
};
ChainDB.prototype.saveSync = function saveSync(entry) {
var self = this;
var raw, offset;
@ -902,7 +910,6 @@ ChainDB.prototype.save = function save(entry) {
return this._write(raw, offset);
};
// This causes weird race conditions with size/count/tip.
ChainDB.prototype.saveAsync = function saveAsync(entry, callback) {
var self = this;
var raw, offset;