mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
whoops small changes
This commit is contained in:
parent
e476fb19bc
commit
bce41be4f7
2 changed files with 7 additions and 7 deletions
12
trie.py
12
trie.py
|
|
@ -32,11 +32,11 @@ class Trie():
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def __get_state(self,node,key):
|
def __get_state(self,node,key):
|
||||||
if debug: print 'nk',node.encode('hex'),key
|
if self.debug: print 'nk',node.encode('hex'),key
|
||||||
if len(key) == 0 or not node:
|
if len(key) == 0 or not node:
|
||||||
return node
|
return node
|
||||||
curnode = rlp.decode(self.db.get(node))
|
curnode = rlp.decode(self.db.get(node))
|
||||||
if debug: print 'cn', curnode
|
if self.debug: print 'cn', curnode
|
||||||
if not curnode:
|
if not curnode:
|
||||||
raise Exception("node not found in database")
|
raise Exception("node not found in database")
|
||||||
elif len(curnode) == 2:
|
elif len(curnode) == 2:
|
||||||
|
|
@ -60,7 +60,7 @@ class Trie():
|
||||||
else: return self.__delete_state(node,key)
|
else: return self.__delete_state(node,key)
|
||||||
|
|
||||||
def __insert_state(self,node,key,value):
|
def __insert_state(self,node,key,value):
|
||||||
if debug: print 'ink', node.encode('hex'), key
|
if self.debug: print 'ink', node.encode('hex'), key
|
||||||
if len(key) == 0:
|
if len(key) == 0:
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
|
|
@ -68,7 +68,7 @@ class Trie():
|
||||||
newnode = [ self.__encode_key(key), value ]
|
newnode = [ self.__encode_key(key), value ]
|
||||||
return self.__put(newnode)
|
return self.__put(newnode)
|
||||||
curnode = rlp.decode(self.db.get(node))
|
curnode = rlp.decode(self.db.get(node))
|
||||||
if debug: print 'icn', curnode
|
if self.debug: print 'icn', curnode
|
||||||
if not curnode:
|
if not curnode:
|
||||||
raise Exception("node not found in database")
|
raise Exception("node not found in database")
|
||||||
if len(curnode) == 2:
|
if len(curnode) == 2:
|
||||||
|
|
@ -100,14 +100,14 @@ class Trie():
|
||||||
return self.__put(newnode)
|
return self.__put(newnode)
|
||||||
|
|
||||||
def __delete_state(self,node,key):
|
def __delete_state(self,node,key):
|
||||||
if debug: print 'dnk', node.encode('hex'), key
|
if self.debug: print 'dnk', node.encode('hex'), key
|
||||||
if len(key) == 0 or not node:
|
if len(key) == 0 or not node:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
curnode = rlp.decode(self.db.get(node))
|
curnode = rlp.decode(self.db.get(node))
|
||||||
if not curnode:
|
if not curnode:
|
||||||
raise Exception("node not found in database")
|
raise Exception("node not found in database")
|
||||||
if debug: print 'dcn', curnode
|
if self.debug: print 'dcn', curnode
|
||||||
if len(curnode) == 2:
|
if len(curnode) == 2:
|
||||||
(k2, v2) = curnode
|
(k2, v2) = curnode
|
||||||
k2 = self.__decode_key(k2)
|
k2 = self.__decode_key(k2)
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,4 @@ def trie_test():
|
||||||
print v1,v2
|
print v1,v2
|
||||||
if v1 != v2: raise Exception("incorrect!")
|
if v1 != v2: raise Exception("incorrect!")
|
||||||
|
|
||||||
|
trie_test()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue