Skip to content

Commit 23773ec

Browse files
committed
fix int to bool map
1 parent 26d1a19 commit 23773ec

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
@@ -463,7 +463,7 @@ async def validate_block_body(
463463
False,
464464
block.foliage_transaction_block.timestamp,
465465
)
466-
removal_coin_records[new_unspent.name] = new_unspent
466+
removal_coin_records[new_unspent.name()] = new_unspent
467467
else:
468468
# This check applies to both coins created before fork (pulled from coin_store),
469469
# and coins created after fork (additions_since_fork)
@@ -485,17 +485,17 @@ async def validate_block_body(
485485
if unspent.spent() == 1 and unspent.spent_block_index <= fork_info.fork_height:
486486
# Check for coins spent in an ancestor block
487487
return Err.DOUBLE_SPEND
488-
removal_coin_records[unspent.name] = unspent
488+
removal_coin_records[unspent.name()] = unspent
489489
else:
490-
look_in_fork.append(unspent.name)
490+
look_in_fork.append(unspent.name())
491491

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

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

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

559559
# 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)