Skip to content

Commit

Permalink
Merge pull request #55 from xian-network/driver-testss
Browse files Browse the repository at this point in the history
Driver testss
  • Loading branch information
crosschainer authored Jun 7, 2024
2 parents ce269d0 + 588ce9e commit ee7daa4
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 989 deletions.
26 changes: 5 additions & 21 deletions src/contracting/storage/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def iter_from_disk(self, prefix="", length=0):

return keys if length == 0 else keys[:length]

def value_from_disk(self, key):
filename, variable = self.__parse_key(key)
return hdf5.get_value_from_disk(self.__filename_to_path(filename), variable)

def items(self, prefix=""):
"""
Get all existing items with a given prefix
Expand Down Expand Up @@ -354,7 +358,7 @@ def get_all_contract_state(self):
filename = file_path.name
keys = self.__get_keys_from_file(self.__filename_to_path(filename))
for key in keys:
full_key = f"{filename}{DELIMITER}{key}"
full_key = f"{key}"
value = hdf5.get_value_from_disk(self.__filename_to_path(filename), key)
all_contract_state[full_key] = value

Expand All @@ -374,23 +378,3 @@ def get_run_state(self):
run_state[full_key] = value

return run_state

def reset_cache(self):
self.cache.clear()

def bust_cache(self, writes: dict):
"""
Remove specific write deltas from the cache
"""
if not writes:
return

for key in writes.keys():
should_clear = True
for pd in self.pending_deltas.values():
should_clear = key not in list(pd["writes"].keys())
if not should_clear:
break

if should_clear:
self.cache.pop(key, None)
Loading

0 comments on commit ee7daa4

Please sign in to comment.