-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransactionPool.py
32 lines (25 loc) · 935 Bytes
/
TransactionPool.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
class TransactionPool():
def __init__(self):
self.transactions = []
def addTransaction(self, transaction):
self.transactions.append(transaction)
def transactionExists(self, transaction):
for poolTransaction in self.transactions:
if poolTransaction.equals(transaction):
return True
return False
def removeFromPool(self, transactions):
newPoolTransactions = []
for poolTransaction in self.transactions:
insert = True
for transaction in transactions:
if poolTransaction.equals(transaction):
insert = False
if insert == True:
newPoolTransactions.append(poolTransaction)
self.transactions = newPoolTransactions
def forgingRequired(self):
if len(self.transactions) >= 1:
return True
else:
return False