Skip to content

Commit bb7b415

Browse files
committed
adding missing node_hash changes, and spaces for parameters
1 parent ee66031 commit bb7b415

File tree

1 file changed

+8
-8
lines changed
  • public/content/developers/docs/data-structures-and-encoding/patricia-merkle-trie

1 file changed

+8
-8
lines changed

public/content/developers/docs/data-structures-and-encoding/patricia-merkle-trie/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,33 @@ There is a difference between looking something up in the 'trie' and the underly
3434
The update and delete operations for radix tries can be defined as follows:
3535

3636
```
37-
def update(node_hash,path,value):
38-
curnode = db.get(node_hash) if node else [ NULL ] * 17
37+
def update(node_hash, path, value):
38+
curnode = db.get(node_hash) if node_hash else [ NULL ] * 17
3939
newnode = curnode.copy()
4040
if path == '':
4141
newnode[-1] = value
4242
else:
43-
newindex = update(curnode[path[0]],path[1:],value)
43+
newindex = update(curnode[path[0]], path[1:], value)
4444
newnode[path[0]] = newindex
45-
db.put(hash(newnode),newnode)
45+
db.put(hash(newnode), newnode)
4646
return hash(newnode)
4747
48-
def delete(node_hash,path):
49-
if node is NULL:
48+
def delete(node_hash, path):
49+
if node_hash is NULL:
5050
return NULL
5151
else:
5252
curnode = db.get(node_hash)
5353
newnode = curnode.copy()
5454
if path == '':
5555
newnode[-1] = NULL
5656
else:
57-
newindex = delete(curnode[path[0]],path[1:])
57+
newindex = delete(curnode[path[0]], path[1:])
5858
newnode[path[0]] = newindex
5959
6060
if all(x is NULL for x in newnode):
6161
return NULL
6262
else:
63-
db.put(hash(newnode),newnode)
63+
db.put(hash(newnode), newnode)
6464
return hash(newnode)
6565
```
6666

0 commit comments

Comments
 (0)