def commit(self, rootHash=None, rootNode=None): if rootNode: rootHash = self._trie._encode_node(rootNode) elif rootHash and isHex(rootHash): if isinstance(rootHash, str): rootHash = rootHash.encode() rootHash = unhexlify(rootHash) elif rootHash: rootHash = rootHash else: rootHash = self.headHash self._kv.put(self.rootHashKey, rootHash)