Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

make sure ZeroDivisionError never happens #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blockchain_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def set_time(self):
self.time_ref = time.time()

def print_time(self, num_tx):
delta = time.time() - self.time_ref
delta = time.time() - self.time_ref + 0000000000.000001
# leaky averages
seconds_per_block, tx_per_second, n = self.avg_time
alpha = (1. + 0.01 * n)/(n+1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.time() is not necessarily monotonous, so this does not prevent delta from being 0.

delta = max(time.time() - self.time_ref, 1e-6) would be more robust

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, testing it right now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been working for 13 days strait.

Expand Down