Skip to content

Commit 2f56e81

Browse files
committed
fix int to bool map
1 parent 1e85abb commit 2f56e81

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
@@ -181,7 +181,8 @@ async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]:
181181
if row is not None:
182182
coin = self.row_to_coin(row)
183183
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
184-
return CoinRecord(coin, row[0], spent_index, row[2], row[6])
184+
coinbase = False if row[2] == 0 else True
185+
return CoinRecord(coin, row[0], spent_index, coinbase, row[6])
185186
return None
186187

187188
async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]:
@@ -207,7 +208,8 @@ async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]
207208
for row in await cursor.fetchall():
208209
coin = self.row_to_coin(row)
209210
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
210-
record = CoinRecord(coin, row[0], spent_index, row[2], row[6])
211+
coinbase = False if row[2] == 0 else True
212+
record = CoinRecord(coin, row[0], spent_index, coinbase, row[6])
211213
coins.append(record)
212214

213215
return coins
@@ -241,7 +243,8 @@ async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
241243
for row in await cursor.fetchall():
242244
if row[1] > 0:
243245
coin = self.row_to_coin(row)
244-
coin_record = CoinRecord(coin, row[0], row[1], row[2], row[6])
246+
coinbase = False if row[2] == 0 else True
247+
coin_record = CoinRecord(coin, row[0], row[1], coinbase, row[6])
245248
coins.append(coin_record)
246249
return coins
247250

@@ -266,7 +269,8 @@ async def get_coin_records_by_puzzle_hash(
266269
for row in await cursor.fetchall():
267270
coin = self.row_to_coin(row)
268271
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
269-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
272+
coinbase = False if row[2] == 0 else True
273+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
270274
return list(coins)
271275

272276
async def get_coin_records_by_puzzle_hashes(
@@ -295,7 +299,8 @@ async def get_coin_records_by_puzzle_hashes(
295299
for row in await cursor.fetchall():
296300
coin = self.row_to_coin(row)
297301
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
298-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
302+
coinbase = False if row[2] == 0 else True
303+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
299304
return list(coins)
300305

301306
async def get_coin_records_by_names(
@@ -322,7 +327,8 @@ async def get_coin_records_by_names(
322327
for row in await cursor.fetchall():
323328
coin = self.row_to_coin(row)
324329
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
325-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
330+
coinbase = False if row[2] == 0 else True
331+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
326332

327333
return list(coins)
328334

@@ -393,7 +399,8 @@ async def get_coin_records_by_parent_ids(
393399
async for row in cursor:
394400
coin = self.row_to_coin(row)
395401
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
396-
coins.add(CoinRecord(coin, row[0], spent_index, row[2], row[6]))
402+
coinbase = False if row[2] == 0 else True
403+
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
397404

398405
return list(coins)
399406

@@ -567,7 +574,8 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
567574
for row in rows:
568575
coin = self.row_to_coin(row)
569576
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
570-
record = CoinRecord(coin, uint32(0), spent_index, row[2], uint64(0))
577+
coinbase = False if row[2] == 0 else True
578+
record = CoinRecord(coin, uint32(0), spent_index, coinbase, uint64(0))
571579
coin_name = bytes32(row[7])
572580
coin_changes[coin_name] = record
573581

@@ -582,7 +590,8 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
582590
)
583591
for row in rows:
584592
coin = self.row_to_coin(row)
585-
record = CoinRecord(coin, row[0], uint32(0), row[2], row[6])
593+
coinbase = False if row[2] == 0 else True
594+
record = CoinRecord(coin, row[0], uint32(0), coinbase, row[6])
586595
coin_name = bytes32(row[7])
587596
if coin_name not in coin_changes:
588597
coin_changes[coin_name] = record

0 commit comments

Comments
 (0)