From 20361590ff406f2e409e9d4d923ca66aa276f398 Mon Sep 17 00:00:00 2001 From: spekulaas Date: Thu, 9 Nov 2023 09:56:16 +0100 Subject: [PATCH] added time to block --- goodchain/src/helpers/TaskHelper.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/goodchain/src/helpers/TaskHelper.py b/goodchain/src/helpers/TaskHelper.py index 88dcfe2..8fc4787 100644 --- a/goodchain/src/helpers/TaskHelper.py +++ b/goodchain/src/helpers/TaskHelper.py @@ -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}")