chaindb: cache 25mb of coins.

This commit is contained in:
Christopher Jeffrey 2016-07-25 01:20:26 -07:00
parent b860894471
commit 8bd52cff0a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -199,15 +199,7 @@ function ChainDB(chain, options) {
this.cacheWindow = (this.network.pow.retargetInterval + 1) * 2 + 100;
// We want to keep the last 5 blocks of unspents in memory.
// Some explanation for the numbers:
// Average block output size: 165kb
// Average number of outputs: 5000
// Average output size: 33.6b
// Average number of outputs per tx: 2.2
// Average size of outputs per tx: 74b
// Average number of txs: 2300
// Key size: 66b (* 2)
this.coinWindow = ((165 * 1024 + 2300 * 4) + (2300 * 66 * 2)) * 5;
this.coinWindow = 25 << 20;
this.coinCache = new bcoin.lru.nil();
this.cacheHash = new bcoin.lru(this.cacheWindow, 1);