1
0

Move away from requiring network and blockchain objects to be able to request local height.

We store it in the config object instead of in the blockchain object.
The blockchain object now refers to its config, and calls refresh_height() to update it.
The network objects also refer to the config rather than the blockchain.

This is the first of many small steps to untangle the verifier from stored state and so
permit the history tab to work in offline mode.  The refactoring will simultaneously clean
up a lot of accumulated cruft.
This commit is contained in:
Neil Booth
2015-05-03 15:19:29 +09:00
parent 25c6a78ae0
commit 175bfae9e6
4 changed files with 22 additions and 25 deletions

View File

@@ -78,6 +78,8 @@ class SimpleConfig(object):
# user config.
self.user_config = read_user_config_function(self.path)
self.refresh_height()
set_config(self) # Make a singleton instance of 'self'
def init_path(self):
@@ -122,6 +124,16 @@ class SimpleConfig(object):
return False
return True
def headers_filename(self):
return os.path.join(self.path, 'blockchain_headers')
def refresh_height(self):
name = self.headers_filename()
if os.path.exists(name):
self.height = os.path.getsize(name) / 80 - 1
else:
self.height = 0
def save_user_config(self):
if not self.path:
return