blockchain: use blockstore for undo coins

This commit is contained in:
Braydon Fuller 2019-03-07 11:54:57 -08:00
parent 89d3253f29
commit 8b6ec89a64
No known key found for this signature in database
GPG Key ID: F24F232D108B3AD4
2 changed files with 7 additions and 7 deletions

View File

@ -770,7 +770,7 @@ class ChainDB {
if (!hash)
throw new Error(`Cannot find hash for ${i}.`);
b.del(layout.u.encode(hash));
await this.blocks.pruneUndo(hash);
await this.blocks.prune(hash);
}
@ -1016,7 +1016,7 @@ class ChainDB {
*/
async getUndoCoins(hash) {
const data = await this.db.get(layout.u.encode(hash));
const data = await this.blocks.readUndo(hash);
if (!data)
return new UndoCoins();
@ -1764,7 +1764,7 @@ class ChainDB {
// Write undo coins (if there are any).
if (!view.undo.isEmpty())
this.put(layout.u.encode(hash), view.undo.commit());
await this.blocks.writeUndo(hash, view.undo.commit());
// Prune height-288 if pruning is enabled.
return this.pruneBlock(entry);
@ -1823,7 +1823,7 @@ class ChainDB {
this.saveView(view);
// Remove undo coins.
this.del(layout.u.encode(hash));
await this.blocks.pruneUndo(hash);
return view;
}
@ -1853,7 +1853,7 @@ class ChainDB {
if (!hash)
return;
this.del(layout.u.encode(hash));
await this.blocks.pruneUndo(hash);
await this.blocks.prune(hash);
}

View File

@ -19,10 +19,10 @@ const bdb = require('bdb');
* H[height] -> hash
* n[hash] -> next hash
* p[hash] -> tip index
* b[hash] -> block
* b[hash] -> block (deprecated)
* t[hash] -> extended tx
* c[hash] -> coins
* u[hash] -> undo coins
* u[hash] -> undo coins (deprecated)
* v[bit][hash] -> versionbits state
* T[addr-hash][hash] -> dummy (tx by address)
* C[addr-hash][hash][index] -> dummy (coin by address)