remove transactions from pool
This commit is contained in:
parent
4a2ea1fa3c
commit
30bb49de03
@ -54,13 +54,15 @@ def createBlock(self):
|
||||
try:
|
||||
lastBlock = utilityHelper.loadFile("../data/ledger.dat")
|
||||
except:
|
||||
lastBlock = None
|
||||
if lastBlock != None:
|
||||
lastBlock = []
|
||||
|
||||
print(lastBlock)
|
||||
if lastBlock != []:
|
||||
lastBlock = lastBlock[-1]
|
||||
|
||||
if lastBlock != None and time.time() - lastBlock.date < 180:
|
||||
print("You can only mine a block every 3 minutes")
|
||||
return False
|
||||
if lastBlock != None and time.time() - lastBlock.date < 180:
|
||||
print("You can only mine a block every 3 minutes")
|
||||
return False
|
||||
|
||||
transactions = Tx()
|
||||
transactions = utilityHelper.loadFile("../data/transaction_pool.dat")
|
||||
@ -128,7 +130,8 @@ def createBlock(self):
|
||||
if only_personal:
|
||||
print("You need atleast 1 transaction from another user")
|
||||
return False
|
||||
|
||||
if lastBlock == []:
|
||||
lastBlock = None
|
||||
block = TxBlock(lastBlock)
|
||||
|
||||
# create block
|
||||
@ -164,6 +167,12 @@ def createBlock(self):
|
||||
utilityHelper.saveFile("../data/ledger.dat", block)
|
||||
# TODO remove transactions from transaction pool
|
||||
|
||||
utilityHelper.resetFile("../data/transaction_pool.dat")
|
||||
transaction_count = 0
|
||||
for transaction in transactions:
|
||||
if transaction_count not in selected_transactions:
|
||||
utilityHelper.saveFile("../data/transaction_pool.dat", transactions[i])
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user