Skip to content

Commit b122daa

Browse files
authored
Merge pull request #12721 from croath/dev
Update patricia merkle trie sample code
2 parents c377037 + d5a7b02 commit b122daa

File tree

1 file changed

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

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ The update and delete operations for radix tries can be defined as follows:
3535

3636
```
3737
def update(node,path,value):
38+
curnode = db.get(node) if node else [ NULL ] * 17
39+
newnode = curnode.copy()
3840
if path == '':
39-
curnode = db.get(node) if node else [ NULL ] * 17
40-
newnode = curnode.copy()
4141
newnode[-1] = value
4242
else:
43-
curnode = db.get(node) if node else [ NULL ] * 17
44-
newnode = curnode.copy()
4543
newindex = update(curnode[path[0]],path[1:],value)
4644
newnode[path[0]] = newindex
4745
db.put(hash(newnode),newnode)

0 commit comments

Comments
 (0)