diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index 20eefea1..96b38493 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -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); } diff --git a/lib/blockchain/layout.js b/lib/blockchain/layout.js index 1bc801d5..01aaa086 100644 --- a/lib/blockchain/layout.js +++ b/lib/blockchain/layout.js @@ -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)