diff --git a/src/xian/driver_api.py b/src/xian/driver_api.py index 482bdcde..49f36ece 100644 --- a/src/xian/driver_api.py +++ b/src/xian/driver_api.py @@ -1,23 +1,23 @@ import xian.constants as c from contracting.db.driver import ( - ContractDriver, + Driver, ) from contracting.stdlib.bridge.decimal import ContractingDecimal -def get_latest_block_hash(driver: ContractDriver): +def get_latest_block_hash(driver: Driver): latest_hash = driver.get(c.LATEST_BLOCK_HASH_KEY) if latest_hash is None: return b"" return latest_hash -def set_latest_block_hash(h, driver: ContractDriver): +def set_latest_block_hash(h, driver: Driver): driver.set(c.LATEST_BLOCK_HASH_KEY, h) -def get_latest_block_height(driver: ContractDriver): +def get_latest_block_height(driver: Driver): h = driver.get(c.LATEST_BLOCK_HEIGHT_KEY, save=False) if h is None: return 0 @@ -28,11 +28,11 @@ def get_latest_block_height(driver: ContractDriver): return int(h) -def set_latest_block_height(h, driver: ContractDriver): +def set_latest_block_height(h, driver: Driver): driver.set(c.LATEST_BLOCK_HEIGHT_KEY, int(h)) -def get_value_of_key(item: str, driver: ContractDriver): +def get_value_of_key(item: str, driver: Driver): return driver.get(item) diff --git a/src/xian/storage.py b/src/xian/storage.py index 9e565bbd..0a2fd8d5 100644 --- a/src/xian/storage.py +++ b/src/xian/storage.py @@ -1,13 +1,12 @@ import xian.constants as c from contracting import config -from contracting.db.driver import FSDriver class NonceStorage: - def __init__(self, root=None): + def __init__(self, root=None, driver=None): root = root if root is not None else c.STORAGE_HOME - self.driver = FSDriver(root=root) + self.driver = driver # Move this to transaction.py def get_nonce(self, sender): diff --git a/src/xian/xian_abci.py b/src/xian/xian_abci.py index 3d9876cb..a4b8dcdb 100644 --- a/src/xian/xian_abci.py +++ b/src/xian/xian_abci.py @@ -10,7 +10,7 @@ from abci.application import BaseApplication from contracting.client import ContractingClient -from contracting.db.driver import ContractDriver +from contracting.db.driver import Driver from xian.methods import ( init_chain, @@ -69,8 +69,8 @@ def __init__(self): raise SystemExit() self.client = ContractingClient() - self.driver = ContractDriver() - self.nonce_storage = NonceStorage() + self.driver = Driver() + self.nonce_storage = NonceStorage(driver=self.driver) self.upgrader = UpgradeHandler(self) self.xian = Node(self.client, self.driver, self.nonce_storage) self.validator_handler = ValidatorHandler(self)