Skip to content

Commit 8a1a962

Browse files
committed
Fix prefix dump
1 parent cbc00ad commit 8a1a962

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/cmd/seidb/operations/state_size.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package operations
22

33
import (
4+
"encoding/json"
45
"fmt"
56

67
"github.com/sei-protocol/sei-db/common/logger"
@@ -71,13 +72,15 @@ func PrintStateSize(module string, db *memiavl.DB) error {
7172
totalKeySize += len(node.Key())
7273
totalValueSize += len(node.Value())
7374
totalSize += len(node.Key()) + len(node.Value())
74-
prefix := string(node.Key()[:2])
75-
sizeByPrefix[prefix] += len(node.Key()) + len(node.Value())
75+
prefix := fmt.Sprintf("%X", node.Key())
76+
prefix = prefix[:2]
77+
sizeByPrefix[prefix] += len(node.Value())
7678
}
7779
return true
7880
})
7981
fmt.Printf("Module %s total numKeys:%d, total keySize:%d, total valueSize:%d, totalSize: %d \n", moduleName, totalNumKeys, totalKeySize, totalValueSize, totalSize)
80-
fmt.Printf("Module %s prefix breakdown: %v \n", moduleName, sizeByPrefix)
82+
result, _ := json.MarshalIndent(sizeByPrefix, "", " ")
83+
fmt.Printf("Module %s prefix breakdown: %s \n", moduleName, result)
8184
}
8285
}
8386
return nil

0 commit comments

Comments
 (0)