Skip to content

Commit b9a0dc1

Browse files
committed
fix int to bool map
1 parent eb855a6 commit b9a0dc1

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

chia/consensus/block_body_validation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ async def validate_block_body(
462462
False,
463463
block.foliage_transaction_block.timestamp,
464464
)
465-
removal_coin_records[new_unspent.name] = new_unspent
465+
removal_coin_records[new_unspent.name()] = new_unspent
466466
else:
467467
# This check applies to both coins created before fork (pulled from coin_store),
468468
# and coins created after fork (additions_since_fork)
@@ -484,17 +484,17 @@ async def validate_block_body(
484484
if unspent.spent == 1 and unspent.spent_block_index <= fork_info.fork_height:
485485
# Check for coins spent in an ancestor block
486486
return Err.DOUBLE_SPEND
487-
removal_coin_records[unspent.name] = unspent
487+
removal_coin_records[unspent.name()] = unspent
488488
else:
489-
look_in_fork.append(unspent.name)
489+
look_in_fork.append(unspent.name())
490490

491491
if log_coins and len(look_in_fork) > 0:
492492
log.info("%d coins spent after fork", len(look_in_fork))
493493

494494
if len(unspent_records) != len(removals_from_db):
495495
# some coins could not be found in the DB. We need to find out which
496496
# ones and look for them in additions_since_fork
497-
found: set[bytes32] = {u.name for u in unspent_records}
497+
found: set[bytes32] = {u.name() for u in unspent_records}
498498
for rem in removals_from_db:
499499
if rem in found:
500500
continue
@@ -552,7 +552,7 @@ async def validate_block_body(
552552

553553
# 20. Verify that removed coin puzzle_hashes match with calculated puzzle_hashes
554554
for unspent in removal_coin_records.values():
555-
if unspent.coin.puzzle_hash != removals_puzzle_dic[unspent.name]:
555+
if unspent.coin.puzzle_hash != removals_puzzle_dic[unspent.name()]:
556556
return Err.WRONG_PUZZLE_HASH
557557

558558
# 21. Verify conditions

chia/full_node/coin_store.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]:
173173
if row is not None:
174174
coin = self.row_to_coin(row)
175175
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
176-
return CoinRecord(coin, row[0], spent_index, row[2], row[6])
176+
coinbase = False if row[2] == 0 else True
177+
return CoinRecord(coin, row[0], spent_index, coinbase, row[6])
177178
return None
178179

179180
async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]:
@@ -199,7 +200,8 @@ async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]
199200
for row in await cursor.fetchall():
200201
coin = self.row_to_coin(row)
201202
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
202-
record = CoinRecord(coin, row[0], spent_index, row[2], row[6])
203+
coinbase = False if row[2] == 0 else True
204+
record = CoinRecord(coin, row[0], spent_index, coinbase, row[6])
203205
coins.append(record)
204206

205207
return coins
@@ -233,7 +235,8 @@ async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
233235
for row in await cursor.fetchall():
234236
if row[1] > 0:
235237
coin = self.row_to_coin(row)
236-
coin_record = CoinRecord(coin, row[0], row[1], row[2], row[6])
238+
coinbase = False if row[2] == 0 else True
239+
coin_record = CoinRecord(coin, row[0], row[1], coinbase, row[6])
237240
coins.append(coin_record)
238241
return coins
239242

@@ -258,7 +261,8 @@ async def get_coin_records_by_puzzle_hash(
258261
for row in await cursor.fetchall():
259262
coin = self.row_to_coin(row)
260263
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
261-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
264+
coinbase = False if row[2] == 0 else True
265+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
262266
return list(coins)
263267

264268
async def get_coin_records_by_puzzle_hashes(
@@ -287,7 +291,8 @@ async def get_coin_records_by_puzzle_hashes(
287291
for row in await cursor.fetchall():
288292
coin = self.row_to_coin(row)
289293
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
290-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
294+
coinbase = False if row[2] == 0 else True
295+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
291296
return list(coins)
292297

293298
async def get_coin_records_by_names(
@@ -314,7 +319,8 @@ async def get_coin_records_by_names(
314319
for row in await cursor.fetchall():
315320
coin = self.row_to_coin(row)
316321
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
317-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
322+
coinbase = False if row[2] == 0 else True
323+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
318324

319325
return list(coins)
320326

@@ -385,7 +391,8 @@ async def get_coin_records_by_parent_ids(
385391
async for row in cursor:
386392
coin = self.row_to_coin(row)
387393
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
388-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
394+
coinbase = False if row[2] == 0 else True
395+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
389396

390397
return list(coins)
391398

@@ -559,7 +566,8 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
559566
for row in rows:
560567
coin = self.row_to_coin(row)
561568
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
562-
record = CoinRecord(coin, uint32(0), spent_index, row[2], uint64(0))
569+
coinbase = False if row[2] == 0 else True
570+
record = CoinRecord(coin, uint32(0), spent_index, coinbase, uint64(0))
563571
coin_name = bytes32(row[7])
564572
coin_changes[coin_name] = record
565573

@@ -574,7 +582,8 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
574582
)
575583
for row in rows:
576584
coin = self.row_to_coin(row)
577-
record = CoinRecord(coin, row[0], uint32(0), row[2], row[6])
585+
coinbase = False if row[2] == 0 else True
586+
record = CoinRecord(coin, row[0], uint32(0), coinbase, row[6])
578587
coin_name = bytes32(row[7])
579588
if coin_name not in coin_changes:
580589
coin_changes[coin_name] = record

0 commit comments

Comments
 (0)