mempool: refactor.

This commit is contained in:
Christopher Jeffrey 2017-02-28 17:18:54 -08:00
parent 3abc47c292
commit 92d896c729
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -113,7 +113,7 @@ Mempool.prototype._open = co(function* open() {
yield this.cache.open();
if (this.options.persistent) {
entries = yield this.cache.load();
entries = yield this.cache.getEntries();
for (i = 0; i < entries.length; i++) {
entry = entries[i];
@ -125,6 +125,10 @@ Mempool.prototype._open = co(function* open() {
this.updateAncestors(entry);
}
this.logger.info(
'Loaded mempool from disk (%d entries).',
entries.length);
if (this.fees) {
fees = yield this.cache.getFees();
@ -2371,6 +2375,7 @@ MempoolCache.prototype.open = co(function* open() {
return;
yield this.db.open();
yield this.verify();
this.batch = this.db.batch();
});
@ -2433,9 +2438,9 @@ MempoolCache.prototype.init = co(function* init(hash) {
yield batch.write();
});
MempoolCache.prototype.load = co(function* load() {
MempoolCache.prototype.verify = co(function* verify() {
var version = yield this.getVersion();
var tip, entries;
var tip;
if (version === -1) {
version = MempoolCache.VERSION;
@ -2455,7 +2460,7 @@ MempoolCache.prototype.load = co(function* load() {
MempoolCache.VERSION);
this.logger.warning('Invalidating mempool cache.');
yield this.wipe();
return [];
return false;
}
tip = yield this.getTip();
@ -2467,16 +2472,10 @@ MempoolCache.prototype.load = co(function* load() {
this.chain.tip.rhash());
this.logger.warning('Invalidating mempool cache.');
yield this.wipe();
return [];
return false;
}
entries = yield this.getEntries();
this.logger.info(
'Loaded mempool from disk (%d entries).',
entries.length);
return entries;
return true;
});
MempoolCache.prototype.wipe = co(function* wipe() {