Skip to content

Commit c1d6a20

Browse files
committed
disconnect-block now uses one write batch
Signed-off-by: Andrew Miller <amiller@dappervision.com>
1 parent b1a1f3e commit c1d6a20

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ChainDb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ def spend_txout(self, txhash, n_idx, batch=None):
212212

213213
return True
214214

215-
def clear_txout(self, txhash, n_idx):
215+
def clear_txout(self, txhash, n_idx, batch=None):
216216
txidx = self.gettxidx(txhash)
217217
if txidx is None:
218218
return False
219219

220220
txidx.spentmask &= ~(1L << n_idx)
221-
self.puttxidx(txhash, txidx)
221+
self.puttxidx(txhash, txidx, batch)
222222

223223
return True
224224

@@ -401,11 +401,11 @@ def disconnect_block(self, block):
401401
outpts = tup[0]
402402

403403
# mark deps as unspent
404+
batch = leveldb.WriteBatch()
404405
for outpt in outpts:
405-
self.clear_txout(outpt[0], outpt[1])
406+
self.clear_txout(outpt[0], outpt[1], batch)
406407

407408
# update tx index and memory pool
408-
batch = leveldb.WriteBatch()
409409
for tx in block.vtx:
410410
tx.calc_sha256()
411411
ser_hash = ser_uint256(tx.sha256)

0 commit comments

Comments
 (0)