Skip to content

Commit

Permalink
create_bundle_from_mempool() doesn't need to be async (Chia-Network#1…
Browse files Browse the repository at this point in the history
…4114)

create_bundle_from_mempool() doesn't need to be async.
  • Loading branch information
AmineKhaldi authored Dec 13, 2022
1 parent 42f6a88 commit cd4874c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions benchmarks/mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ async def add_spend_bundles(spend_bundles: List[SpendBundle]) -> None:

with enable_profiler(True, f"create-{suffix}"):
start = monotonic()
for i in range(2000):
await mempool.create_bundle_from_mempool(bytes32(b"a" * 32))
for _ in range(2000):
mempool.create_bundle_from_mempool(bytes32(b"a" * 32))
stop = monotonic()
print(f"create_bundle_from_mempool time: {stop - start:0.4f}s")

Expand Down
2 changes: 1 addition & 1 deletion chia/clvm/spend_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def farm_block(
if (len(self.block_records) > 0) and (self.mempool_manager.mempool.spends):
peak = self.mempool_manager.peak
if peak is not None:
result = await self.mempool_manager.create_bundle_from_mempool(peak.header_hash, item_inclusion_filter)
result = self.mempool_manager.create_bundle_from_mempool(peak.header_hash, item_inclusion_filter)

if result is not None:
bundle, additions, removals = result
Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/full_node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ async def declare_proof_of_space(
while not curr_l_tb.is_transaction_block:
curr_l_tb = self.full_node.blockchain.block_record(curr_l_tb.prev_hash)
try:
mempool_bundle = await self.full_node.mempool_manager.create_bundle_from_mempool(
mempool_bundle = self.full_node.mempool_manager.create_bundle_from_mempool(
curr_l_tb.header_hash
)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def process_mempool_items(
additions.extend(item.additions)
return (spend_bundles, uint64(cost_sum), additions, removals)

async def create_bundle_from_mempool(
def create_bundle_from_mempool(
self,
last_tb_header_hash: bytes32,
item_inclusion_filter: Optional[Callable[[MempoolManager, MempoolItem], bool]] = None,
Expand Down
4 changes: 2 additions & 2 deletions chia/simulator/full_node_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def farm_new_transaction_block(
else:
current_time = False
time_per_block = 1
mempool_bundle = await self.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
mempool_bundle = self.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
if mempool_bundle is None:
spend_bundle = None
else:
Expand Down Expand Up @@ -243,7 +243,7 @@ async def farm_new_block(self, request: FarmNewBlockProtocol, force_wait_for_tim
else:
current_time = False
time_per_block = 1
mempool_bundle = await self.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
mempool_bundle = self.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
if mempool_bundle is None:
spend_bundle = None
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/blockchain/test_blockchain_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def test_basic_blockchain_tx(self, two_nodes):
assert sb is spend_bundle

last_block = blocks[-1]
next_spendbundle, additions, removals = await full_node_1.mempool_manager.create_bundle_from_mempool(
next_spendbundle, additions, removals = full_node_1.mempool_manager.create_bundle_from_mempool(
last_block.header_hash
)
assert next_spendbundle is not None
Expand Down
2 changes: 1 addition & 1 deletion tests/core/full_node/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def test_full_block_performance(self, request: pytest.FixtureRequest, wall
curr: BlockRecord = peak
while not curr.is_transaction_block:
curr = full_node_1.full_node.blockchain.block_record(curr.prev_hash)
mempool_bundle = await full_node_1.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
mempool_bundle = full_node_1.full_node.mempool_manager.create_bundle_from_mempool(curr.header_hash)
if mempool_bundle is None:
spend_bundle = None
else:
Expand Down

0 comments on commit cd4874c

Please sign in to comment.