chaindb: minor.

This commit is contained in:
Christopher Jeffrey 2017-07-09 13:17:43 -07:00
parent 0ffabd7a9a
commit 797016630c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1467,8 +1467,10 @@ ChainDB.prototype.saveUpdates = function saveUpdates() {
this.logger.info('Saving %d state cache updates.', updates.length);
for (let update of updates)
this.put(layout.v(update.bit, update.hash), update.toRaw());
for (let update of updates) {
let {bit, hash} = update;
this.put(layout.v(bit, hash), update.toRaw());
}
};
/**
@ -2122,9 +2124,9 @@ StateCache.prototype._init = function _init() {
for (let i = 0; i < 32; i++)
this.bits.push(null);
for (let deployment of this.network.deploys) {
assert(!this.bits[deployment.bit]);
this.bits[deployment.bit] = new Map();
for (let {bit} of this.network.deploys) {
assert(!this.bits[bit]);
this.bits[bit] = new Map();
}
};
@ -2158,12 +2160,10 @@ StateCache.prototype.commit = function commit() {
};
StateCache.prototype.drop = function drop() {
let update, cache;
for (update of this.updates) {
cache = this.bits[update.bit];
for (let {bit, hash} of this.updates) {
let cache = this.bits[bit];
assert(cache);
cache.delete(update.hash);
cache.delete(hash);
}
this.updates.length = 0;