From 3295f8aa82690fa136599dfeac26aeb0bda159b5 Mon Sep 17 00:00:00 2001 From: maskpp Date: Thu, 13 Jun 2024 01:47:24 +0800 Subject: [PATCH] clone map by maps.Clone --- triedb/pathdb/nodebuffer.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/triedb/pathdb/nodebuffer.go b/triedb/pathdb/nodebuffer.go index ff09484100..d3492602c8 100644 --- a/triedb/pathdb/nodebuffer.go +++ b/triedb/pathdb/nodebuffer.go @@ -19,6 +19,7 @@ package pathdb import ( "bytes" "fmt" + "maps" "time" "github.com/VictoriaMetrics/fastcache" @@ -90,12 +91,10 @@ func (b *nodebuffer) commit(nodes map[common.Hash]map[string]*trienode.Node) *no // The nodes belong to original diff layer are still accessible even // after merging, thus the ownership of nodes map should still belong // to original layer and any mutation on it should be prevented. - current = make(map[string]*trienode.Node, len(subset)) for path, n := range subset { - current[path] = n delta += int64(len(n.Blob) + len(path)) } - b.nodes[owner] = current + b.nodes[owner] = maps.Clone(subset) continue } for path, n := range subset {