Skip to content

Commit

Permalink
Stop assuming True == 1 (#10396)
Browse files Browse the repository at this point in the history
* Stop assuming `True == 1`

* Removed unnecessary lines which confuses code readers
  • Loading branch information
ChiaMineJP committed Feb 25, 2022
1 parent fdb993c commit ae61ed7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions chia/full_node/mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ async def add_spendbundle(
return uint64(cost), MempoolInclusionStatus.SUCCESS, None

removal_record_dict: Dict[bytes32, CoinRecord] = {}
removal_coin_dict: Dict[bytes32, Coin] = {}
removal_amount: int = 0
for name in removal_names:
removal_record = await self.coin_store.get_coin_record(name)
Expand All @@ -362,9 +361,8 @@ async def add_spendbundle(
assert removal_record is not None
removal_amount = removal_amount + removal_record.coin.amount
removal_record_dict[name] = removal_record
removal_coin_dict[name] = removal_record.coin

removals: List[Coin] = [coin for coin in removal_coin_dict.values()]
removals: List[Coin] = [record.coin for record in removal_record_dict.values()]

if addition_amount > removal_amount:
return None, MempoolInclusionStatus.FAILED, Err.MINTING_COIN
Expand Down Expand Up @@ -401,7 +399,6 @@ async def add_spendbundle(
# Use this information later when constructing a block
fail_reason, conflicts = await self.check_removals(removal_record_dict)
# If there is a mempool conflict check if this spendbundle has a higher fee per cost than all others
tmp_error: Optional[Err] = None
conflicting_pool_items: Dict[bytes32, MempoolItem] = {}
if fail_reason is Err.MEMPOOL_CONFLICT:
for conflicting in conflicts:
Expand All @@ -421,9 +418,6 @@ async def add_spendbundle(
elif fail_reason:
return None, MempoolInclusionStatus.FAILED, fail_reason

if tmp_error:
return None, MempoolInclusionStatus.FAILED, tmp_error

# Verify conditions, create hash_key list for aggsig check
error: Optional[Err] = None
for npc in npc_list:
Expand Down Expand Up @@ -487,7 +481,7 @@ async def check_removals(self, removals: Dict[bytes32, CoinRecord]) -> Tuple[Opt
for record in removals.values():
removal = record.coin
# 1. Checks if it's been spent already
if record.spent == 1:
if record.spent:
return Err.DOUBLE_SPEND, []
# 2. Checks if there's a mempool conflict
if removal.name() in self.mempool.removals:
Expand Down

0 comments on commit ae61ed7

Please sign in to comment.