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