-
Notifications
You must be signed in to change notification settings - Fork 3
/
output.py
66 lines (44 loc) · 1.78 KB
/
output.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Naman Gupta
# output.py
# namangupta9@gmail.com | namang@umich.edu
import transaction
import heapq
def print_transactors():
print("Transactors: Alpha, Bravo, Charlie, & Delta")
print("All Transactors Begin with 100 Units of Currency\n")
def print_blockchain(blockchain_in):
print("Blockchain Height: " + str(blockchain_in[-1].block_height))
print("-----------------------------------------")
if len(blockchain_in) > 0:
print(blockchain_in[-1])
if len(blockchain_in) > 1:
print(blockchain_in[-2])
if len(blockchain_in) > 2:
print(blockchain_in[-3])
def print_transaction_pool(transactions_in, transactors_in):
print("Transaction Pool: ")
print("-----------------")
index = 0
for t in heapq.nsmallest(6, transactions_in):
print("Priority " + str(index) + ": " + transaction.transaction_str(t[-1]))
index += 1
print("\n")
def print_final(transactors_in):
# Final Outputs
print("\nTransactors' Final Blockchain:")
print_blockchain(transactors_in[0].blockchain)
print("\nAlpha's Final Unspent Transaction Output (UTXO's) Pool")
print_utxo_pool(transactors_in[0].utxo_pool)
print("\nBravo's Final Unspent Transaction Outputs (UTXO's) Pool")
print_utxo_pool(transactors_in[1].utxo_pool)
print("\nCharlie's Final Unspent Transaction Outputs (UTXO's) Pool")
print_utxo_pool(transactors_in[2].utxo_pool)
print("\nDelta's Final Unspent Transaction Outputs (UTXO's) Pool")
print_utxo_pool(transactors_in[3].utxo_pool)
def print_utxo_pool(utxo_pool_in):
print("---------------------------------------------------------")
sum = 0
for u in utxo_pool_in:
print(str(u))
sum += u.value
print("UTXO Balance: " + str(sum) + '\n')