Created
June 29, 2017 11:48
-
-
Save janx/8983198d7de676427762155c01ee9be1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ethereum/pow/chain.py b/ethereum/pow/chain.py | |
index 45f856e..1c6ea4e 100644 | |
--- a/ethereum/pow/chain.py | |
+++ b/ethereum/pow/chain.py | |
@@ -81,7 +81,6 @@ class Chain(object): | |
self.genesis = self.get_block_by_number(0) | |
self.time_queue = [] | |
self.parent_queue = {} | |
- self.localtime = time.time() if localtime is None else localtime | |
# Head (tip) of the chain | |
@property | |
@@ -220,11 +219,15 @@ class Chain(object): | |
return score | |
+ def get_time(self): | |
+ return time.time() | |
+ | |
# This function should be called periodically so as to | |
# process blocks that were received but laid aside because | |
# they were received too early | |
def process_time_queue(self, new_time=None): | |
- self.localtime = time.time() if new_time is None else new_time | |
+ if not new_time: | |
+ new_time = self.get_time() | |
i = 0 | |
while i < len(self.time_queue) and self.time_queue[i].timestamp <= new_time: | |
log.info('Adding scheduled block') | |
@@ -235,7 +238,7 @@ class Chain(object): | |
# Call upon receiving a block | |
def add_block(self, block): | |
- now = self.localtime | |
+ now = self.get_time() | |
# Are we receiving the block too early? | |
if block.header.timestamp > now: | |
i = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment