from ledger.stores.hash_store import HashStore


# TODO: The api has changed for FileHashStore and OrientDBStore and
# should be changed here too
class MemoryHashStore(HashStore):
    def __init__(self):
        self._nodes = []
        self._leafs = []

    def writeLeaf(self, leafHash):
        self._leafs.append(leafHash)

    def writeNode(self, nodeHash):
        self._nodes.append(nodeHash)

    def readLeaf(self, pos):
        return self._leafs[pos - 1]

    def readNode(self, pos):
        return self._nodes[pos - 1]

    def readLeafs(self, startpos, endpos):
        return (n for n in self._leafs[startpos-1:endpos-1])

    def readNodes(self, startpos, endpos):
        return (n for n in self._nodes[startpos-1:endpos-1])

    @property
    def leafCount(self) -> int:
        return len(self._leafs)

    @property
    def nodeCount(self) -> int:
        return len(self._nodes)
@@ -214,44 +214,15 @@
 elf.
-_nodes = %5B%5D%0A        self._leafs = %5B%5D
+reset()
 %0A%0A  
@@ -863,8 +863,80 @@
 ._nodes)
+%0A%0A    def reset(self):%0A        self._nodes = %5B%5D%0A        self._leafs = %5B%5D

implement reset for MemoryHashStore