Skip to content

Commit 9f228cd

Browse files
committed
Make TransactionQueue's put synchronous.
1 parent 8d4cbab commit 9f228cd

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

chia/_tests/core/full_node/test_tx_processing_queue.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def test_local_txs(seeded_random: random.Random) -> None:
3030
transaction_queue = TransactionQueue(1000, log)
3131
# test 1 tx
3232
first_tx = get_transaction_queue_entry(None, 0)
33-
await transaction_queue.put(first_tx, None)
33+
transaction_queue.put(first_tx, None)
3434

3535
result1 = await transaction_queue.pop()
3636

@@ -40,7 +40,7 @@ async def test_local_txs(seeded_random: random.Random) -> None:
4040
num_txs = 2000
4141
list_txs = [get_transaction_queue_entry(bytes32.random(seeded_random), i) for i in range(num_txs)]
4242
for tx in list_txs:
43-
await transaction_queue.put(tx, None)
43+
transaction_queue.put(tx, None)
4444

4545
resulting_txs = []
4646
for _ in range(num_txs):
@@ -58,12 +58,12 @@ async def test_one_peer_and_await(seeded_random: random.Random) -> None:
5858

5959
list_txs = [get_transaction_queue_entry(peer_id, i) for i in range(num_txs)]
6060
for tx in list_txs:
61-
await transaction_queue.put(tx, peer_id)
61+
transaction_queue.put(tx, peer_id)
6262

6363
# test transaction priority
6464
local_txs = [get_transaction_queue_entry(None, i) for i in range(int(num_txs / 5))] # 20 txs
6565
for tx in local_txs:
66-
await transaction_queue.put(tx, None)
66+
transaction_queue.put(tx, None)
6767

6868
resulting_txs = []
6969
for _ in range(num_txs + len(local_txs)):
@@ -80,7 +80,7 @@ async def test_one_peer_and_await(seeded_random: random.Random) -> None:
8080
with pytest.raises(asyncio.InvalidStateError): # task is not done, so we expect an error when getting result
8181
task.result()
8282
# add a tx to test task completion
83-
await transaction_queue.put(get_transaction_queue_entry(None, 0), None)
83+
transaction_queue.put(get_transaction_queue_entry(None, 0), None)
8484
await asyncio.wait_for(task, 1) # we should never time out here
8585

8686

@@ -95,7 +95,7 @@ async def test_lots_of_peers(seeded_random: random.Random) -> None:
9595
# 100 txs per peer
9696
list_txs = [get_transaction_queue_entry(peer_id, i) for peer_id in peer_ids for i in range(num_txs)]
9797
for tx in list_txs:
98-
await transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
98+
transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
9999

100100
resulting_txs = []
101101
for _ in range(total_txs):
@@ -117,11 +117,11 @@ async def test_full_queue(seeded_random: random.Random) -> None:
117117
# 999 txs per peer then 1 to fail later
118118
list_txs = [get_transaction_queue_entry(peer_id, i) for peer_id in peer_ids for i in range(num_txs)]
119119
for tx in list_txs:
120-
await transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
120+
transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
121121

122122
# test failure case.
123123
with pytest.raises(TransactionQueueFull):
124-
await transaction_queue.put(get_transaction_queue_entry(peer_ids[0], 1001), peer_ids[0])
124+
transaction_queue.put(get_transaction_queue_entry(peer_ids[0], 1001), peer_ids[0])
125125

126126
resulting_txs = []
127127
for _ in range(total_txs):
@@ -142,7 +142,7 @@ async def test_queue_cleanup_and_fairness(seeded_random: random.Random) -> None:
142142

143143
list_txs = peer_tx_a + peer_tx_b + peer_tx_c
144144
for tx in list_txs:
145-
await transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
145+
transaction_queue.put(tx, tx.peer_id) # type: ignore[attr-defined]
146146

147147
resulting_ids = []
148148
for _ in range(3): # we validate we get one transaction per peer

chia/full_node/full_node_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ async def respond_transaction(
310310

311311
# TODO: Use fee in priority calculation, to prioritize high fee TXs
312312
try:
313-
await self.full_node.transaction_queue.put(
313+
self.full_node.transaction_queue.put(
314314
TransactionQueueEntry(tx.transaction, tx_bytes, spend_name, peer, test, peers_with_tx),
315315
peer.peer_node_id,
316316
)
@@ -1434,7 +1434,7 @@ async def send_transaction(self, request: wallet_protocol.SendTransaction, *, te
14341434
return make_msg(ProtocolMessageTypes.transaction_ack, response)
14351435

14361436
queue_entry = TransactionQueueEntry(request.transaction, None, spend_name, None, test)
1437-
await self.full_node.transaction_queue.put(queue_entry, peer_id=None, high_priority=True)
1437+
self.full_node.transaction_queue.put(queue_entry, peer_id=None, high_priority=True)
14381438
try:
14391439
with anyio.fail_after(delay=45):
14401440
status, error = await queue_entry.done.wait()

chia/full_node/tx_processing_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, peer_size_limit: int, log: logging.Logger) -> None:
9999
self.peer_size_limit = peer_size_limit
100100
self.log = log
101101

102-
async def put(self, tx: TransactionQueueEntry, peer_id: bytes32 | None, high_priority: bool = False) -> None:
102+
def put(self, tx: TransactionQueueEntry, peer_id: bytes32 | None, high_priority: bool = False) -> None:
103103
if peer_id is None or high_priority: # when it's local there is no peer_id.
104104
self._high_priority_queue.put(tx)
105105
else:

0 commit comments

Comments
 (0)