Skip to content

Commit 6506072

Browse files
committed
feat(trie): add explain for #6608
1 parent 990f7f9 commit 6506072

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

framework/src/main/java/org/tron/core/trie/TrieImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ private Node insert(Node n, TrieKey k, Object nodeOrValue) {
179179
} else {
180180
TrieKey currentNodeKey = n.kvNodeGetKey();
181181
TrieKey commonPrefix = k.getCommonPrefix(currentNodeKey);
182+
// NOTE: equals(k) MUST precede isEmpty(). They overlap only when both k and
183+
// currentNodeKey are empty (duplicate put on a fully-split KV leaf); in that
184+
// case the correct behavior is an in-place value update, not conversion to
185+
// a BranchNode. Swapping the order corrupts the trie structure. See #6608.
182186
if (commonPrefix.equals(k)) {
183187
return n.kvNodeSetValueOrNode(nodeOrValue);
184188
} else if (commonPrefix.isEmpty()) {

0 commit comments

Comments
 (0)