added time to block
This commit is contained in:
parent
2d60686f38
commit
20361590ff
@ -121,8 +121,7 @@ def createBlock(self):
|
||||
# add block to blockchain
|
||||
block.time = elapsed
|
||||
block.nonce = nonce
|
||||
# TODO ADD DATE
|
||||
block.date = None
|
||||
block.date = time.time()
|
||||
utilityHelper.saveFile("../data/ledger.dat", block)
|
||||
# TODO remove transactions from transaction pool
|
||||
|
||||
@ -137,8 +136,11 @@ def exploreBlocks(self):
|
||||
x += 1
|
||||
total_transactions += len(block.data)
|
||||
print(f"---------------------------------------{x}-------------------------------------------")
|
||||
print(f"Block created: {block.date}")
|
||||
print(f"Block created: {time.strftime('%Y-%m-%d', time.localtime(block.date))}")
|
||||
print("---------------------------------------END-------------------------------------------")
|
||||
print(f"Total blocks: {x}")
|
||||
print(f"Total transactions: {total_transactions}")
|
||||
print("-----------------------------------------------------------------------------------")
|
||||
print("Select a number to view the block, keep empty to return.")
|
||||
user_input = input(">>: ")
|
||||
if user_input == "":
|
||||
@ -159,7 +161,7 @@ def exploreBlocks(self):
|
||||
# print all info of the block
|
||||
utilityHelper.clearScreen()
|
||||
print(f"---------------------------------------{user_input +1}-------------------------------------------")
|
||||
print(f"Block created: {blocks[user_input].date}")
|
||||
print(f"Block created: {time.strftime('%Y-%m-%d', time.localtime(blocks[user_input].date))}")
|
||||
print(f"Block hash: {blocks[user_input].blockHash}")
|
||||
print(f"Block nonce: {blocks[user_input].nonce}")
|
||||
print(f"Block mined time: {blocks[user_input].time}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user