-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_pos.py
33 lines (25 loc) · 1 KB
/
update_pos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from transactions import *
def Themis_update_positions(transactions, path):
"""
Order transactions based on their assigned_timestamp and update their positions.
:param transactions: List of Transaction objects.
"""
transactions.sort(key=lambda x: x.ID)
for idx, id in enumerate(path):
transactions[id].pos = idx
def update_positions(transactions):
"""
Order transactions based on their assigned_timestamp and update their positions.
:param transactions: List of Transaction objects.
"""
transactions.sort(key=lambda x: x.assigned_timestamp)
for idx, transaction in enumerate(transactions):
transaction.pos = idx
def DAG_update_positions(transactions):
"""
Order transactions based on their assigned_timestamp and update their positions.
:param transactions: List of Transaction objects.
"""
transactions.sort(key=lambda x: x.DAG_assigned_timestamp)
for idx, transaction in enumerate(transactions):
transaction.DAG_pos = idx