blockchain: remove coin cache
This commit is contained in:
parent
2b2e53d83d
commit
a9ebeb3871
@ -44,6 +44,9 @@
|
||||
|
||||
- Pool options now has a `--discover` option exposed, and the `--only` node
|
||||
option will disable discovery of new nodes.
|
||||
- The option for `coin-cache` has been removed, this setting was causing
|
||||
issues during the sync with out-of-memory errors and was making performance
|
||||
worse instead of better.
|
||||
|
||||
### Script changes
|
||||
|
||||
|
||||
@ -61,7 +61,6 @@ const node = new FullNode({
|
||||
prune: true,
|
||||
network: 'main',
|
||||
memory: false,
|
||||
coinCache: 30,
|
||||
logConsole: true,
|
||||
workers: true,
|
||||
workerFile: '/worker.js',
|
||||
|
||||
@ -87,9 +87,6 @@ database and must be passed in consistently.
|
||||
- `prune`: Prune from the last 288 blocks (default: false).
|
||||
- `checkpoints`: Use checkpoints and getheaders for the initial
|
||||
sync (default: true).
|
||||
- `coin-cache`: The size (in MB) of the in-memory UTXO cache. By default,
|
||||
there is no UTXO cache enabled. To get a good number of cache hits per
|
||||
block, the coin cache has to be fairly large (60-100mb recommended at least).
|
||||
- `index-tx`: Index transactions (enables transaction endpoints in REST api)
|
||||
(default: false).
|
||||
- `index-address`: Index transactions and utxos by address (default: false).
|
||||
|
||||
@ -37,7 +37,6 @@ log-file: true
|
||||
|
||||
prune: false
|
||||
checkpoints: true
|
||||
coin-cache: 0
|
||||
entry-cache: 5000
|
||||
index-tx: false
|
||||
index-address: false
|
||||
|
||||
@ -79,9 +79,6 @@ class Chain extends AsyncEmitter {
|
||||
if (this.options.checkpoints)
|
||||
this.logger.info('Checkpoints are enabled.');
|
||||
|
||||
if (this.options.coinCache)
|
||||
this.logger.info('Coin cache is enabled.');
|
||||
|
||||
if (this.options.bip91)
|
||||
this.logger.warning('BIP91 enabled. Segsignal will be enforced.');
|
||||
|
||||
@ -1535,11 +1532,6 @@ class Chain extends AsyncEmitter {
|
||||
block.getSize(),
|
||||
block.txs.length,
|
||||
elapsed);
|
||||
|
||||
if (this.db.coinCache.capacity > 0) {
|
||||
this.logger.debug('Coin Cache: size=%dmb, items=%d.',
|
||||
this.db.coinCache.size / (1 << 20), this.db.coinCache.items);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2687,7 +2679,6 @@ class ChainOptions {
|
||||
this.indexAddress = false;
|
||||
this.forceFlags = false;
|
||||
|
||||
this.coinCache = 0;
|
||||
this.entryCache = 5000;
|
||||
this.maxOrphans = 20;
|
||||
this.checkpoints = true;
|
||||
@ -2786,11 +2777,6 @@ class ChainOptions {
|
||||
this.bip148 = options.bip148;
|
||||
}
|
||||
|
||||
if (options.coinCache != null) {
|
||||
assert((options.coinCache >>> 0) === options.coinCache);
|
||||
this.coinCache = options.coinCache;
|
||||
}
|
||||
|
||||
if (options.entryCache != null) {
|
||||
assert((options.entryCache >>> 0) === options.entryCache);
|
||||
this.entryCache = options.entryCache;
|
||||
|
||||
@ -47,7 +47,6 @@ class ChainDB {
|
||||
this.pending = null;
|
||||
this.current = null;
|
||||
|
||||
this.coinCache = new LRU(this.options.coinCache, getSize, BufferMap);
|
||||
this.cacheHash = new LRU(this.options.entryCache, null, BufferMap);
|
||||
this.cacheHeight = new LRU(this.options.entryCache);
|
||||
}
|
||||
@ -118,7 +117,6 @@ class ChainDB {
|
||||
this.current = this.db.batch();
|
||||
this.pending = this.state.clone();
|
||||
|
||||
this.coinCache.start();
|
||||
this.cacheHash.start();
|
||||
this.cacheHeight.start();
|
||||
|
||||
@ -170,7 +168,6 @@ class ChainDB {
|
||||
this.current = null;
|
||||
this.pending = null;
|
||||
|
||||
this.coinCache.drop();
|
||||
this.cacheHash.drop();
|
||||
this.cacheHeight.drop();
|
||||
this.stateCache.drop();
|
||||
@ -192,7 +189,6 @@ class ChainDB {
|
||||
} catch (e) {
|
||||
this.current = null;
|
||||
this.pending = null;
|
||||
this.coinCache.drop();
|
||||
this.cacheHash.drop();
|
||||
this.cacheHeight.drop();
|
||||
throw e;
|
||||
@ -209,7 +205,6 @@ class ChainDB {
|
||||
this.current = null;
|
||||
this.pending = null;
|
||||
|
||||
this.coinCache.commit();
|
||||
this.cacheHash.commit();
|
||||
this.cacheHeight.commit();
|
||||
this.stateCache.commit();
|
||||
@ -923,22 +918,12 @@ class ChainDB {
|
||||
return null;
|
||||
|
||||
const {hash, index} = prevout;
|
||||
const key = prevout.toKey();
|
||||
const state = this.state;
|
||||
|
||||
const cache = this.coinCache.get(key);
|
||||
|
||||
if (cache)
|
||||
return CoinEntry.fromRaw(cache);
|
||||
|
||||
const raw = await this.db.get(layout.c.encode(hash, index));
|
||||
|
||||
if (!raw)
|
||||
return null;
|
||||
|
||||
if (state === this.state)
|
||||
this.coinCache.set(key, raw);
|
||||
|
||||
return CoinEntry.fromRaw(raw);
|
||||
}
|
||||
|
||||
@ -1722,17 +1707,12 @@ class ChainDB {
|
||||
for (const [index, coin] of coins.outputs) {
|
||||
if (coin.spent) {
|
||||
this.del(layout.c.encode(hash, index));
|
||||
if (this.coinCache.capacity > 0)
|
||||
this.coinCache.unpush(Outpoint.toKey(hash, index));
|
||||
continue;
|
||||
}
|
||||
|
||||
const raw = coin.toRaw();
|
||||
|
||||
this.put(layout.c.encode(hash, index), raw);
|
||||
|
||||
if (this.coinCache.capacity > 0)
|
||||
this.coinCache.push(Outpoint.toKey(hash, index), raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2281,10 +2261,6 @@ class CacheUpdate {
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
function getSize(value) {
|
||||
return value.length + 80;
|
||||
}
|
||||
|
||||
function fromU32(num) {
|
||||
const data = Buffer.allocUnsafe(4);
|
||||
data.writeUInt32LE(num, 0, true);
|
||||
|
||||
@ -54,7 +54,6 @@ class FullNode extends Node {
|
||||
bip148: this.config.bool('bip148'),
|
||||
prune: this.config.bool('prune'),
|
||||
checkpoints: this.config.bool('checkpoints'),
|
||||
coinCache: this.config.mb('coin-cache'),
|
||||
entryCache: this.config.uint('entry-cache'),
|
||||
indexTX: this.config.bool('index-tx'),
|
||||
indexAddress: this.config.bool('index-address')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user