forked from hclivess/nado
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpool_ops.py
More file actions
24 lines (16 loc) · 780 Bytes
/
pool_ops.py
File metadata and controls
24 lines (16 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from data_ops import get_byte_size, sort_list_dict
from transaction_ops import max_from_transaction_pool
def merge_buffer(from_buffer, to_buffer, limit) -> dict:
"""tool to transition between 3 transaction buffers"""
while get_byte_size(to_buffer) < limit and from_buffer:
to_buffer = sort_list_dict(to_buffer)
tx_to_merge = max_from_transaction_pool(from_buffer, key="fee")
if tx_to_merge not in to_buffer:
to_buffer.append(tx_to_merge)
from_buffer.remove(tx_to_merge)
from_buffer = sort_list_dict(from_buffer)
return {"from_buffer": from_buffer,
"to_buffer": to_buffer}
def get_from_pool(pool, source, target):
for item in pool.copy().items():
target[item[0]] = item[1][source]