@@ -529,32 +529,32 @@ async def rollback_to_block(self, block_index: int) -> list[CoinRecord]:
529
529
coin_changes : dict [bytes32 , CoinRecord ] = {}
530
530
# Add coins that are confirmed in the reverted blocks to the list of updated coins.
531
531
async with self .db_wrapper .writer_maybe_transaction () as conn :
532
- async with conn .execute (
532
+ rows = await conn .execute_fetchall (
533
533
"SELECT confirmed_index, spent_index, coinbase, puzzle_hash, "
534
534
"coin_parent, amount, timestamp, coin_name FROM coin_record WHERE confirmed_index>?" ,
535
535
(block_index ,),
536
- ) as cursor :
537
- for row in await cursor . fetchall () :
538
- coin = self .row_to_coin (row )
539
- record = CoinRecord (coin , uint32 (0 ), row [1 ], row [2 ], uint64 (0 ))
540
- coin_name = bytes32 (row [7 ])
541
- coin_changes [coin_name ] = record
536
+ )
537
+ for row in rows :
538
+ coin = self .row_to_coin (row )
539
+ record = CoinRecord (coin , uint32 (0 ), row [1 ], row [2 ], uint64 (0 ))
540
+ coin_name = bytes32 (row [7 ])
541
+ coin_changes [coin_name ] = record
542
542
543
543
# Delete reverted blocks from storage
544
544
await conn .execute ("DELETE FROM coin_record WHERE confirmed_index>?" , (block_index ,))
545
545
546
546
# Add coins that are confirmed in the reverted blocks to the list of changed coins.
547
- async with conn .execute (
547
+ rows = await conn .execute_fetchall (
548
548
"SELECT confirmed_index, spent_index, coinbase, puzzle_hash, "
549
549
"coin_parent, amount, timestamp, coin_name FROM coin_record WHERE spent_index>?" ,
550
550
(block_index ,),
551
- ) as cursor :
552
- for row in await cursor . fetchall () :
553
- coin = self .row_to_coin (row )
554
- record = CoinRecord (coin , row [0 ], uint32 (0 ), row [2 ], row [6 ])
555
- coin_name = bytes32 (row [7 ])
556
- if coin_name not in coin_changes :
557
- coin_changes [coin_name ] = record
551
+ )
552
+ for row in rows :
553
+ coin = self .row_to_coin (row )
554
+ record = CoinRecord (coin , row [0 ], uint32 (0 ), row [2 ], row [6 ])
555
+ coin_name = bytes32 (row [7 ])
556
+ if coin_name not in coin_changes :
557
+ coin_changes [coin_name ] = record
558
558
559
559
await conn .execute ("UPDATE coin_record SET spent_index=0 WHERE spent_index>?" , (block_index ,))
560
560
return list (coin_changes .values ())
0 commit comments