Skip to content

Commit 1649310

Browse files
cmd/geth: rebased and fixed conflicts
1 parent 50b1577 commit 1649310

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

cmd/geth/dbcmd.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
"github.com/ethereum/go-ethereum/log"
4242
"github.com/ethereum/go-ethereum/rlp"
4343
"github.com/ethereum/go-ethereum/trie"
44-
"github.com/ethereum/go-ethereum/trie/triedb/pathdb"
4544
"github.com/ethereum/go-ethereum/triedb"
4645
"github.com/olekukonko/tablewriter"
4746
"github.com/urfave/cli/v2"
@@ -340,7 +339,9 @@ func inspectTrie(ctx *cli.Context) error {
340339
var headerBlockHash common.Hash
341340
if ctx.Args().Get(0) == "latest" {
342341
headerHash := rawdb.ReadHeadHeaderHash(db)
343-
blockNumber = *(rawdb.ReadHeaderNumber(db, headerHash))
342+
if num := rawdb.ReadHeaderNumber(db, headerHash); num != nil {
343+
blockNumber = *num
344+
}
344345
} else if ctx.Args().Get(0) == "snapshot" {
345346
trieRootHash = rawdb.ReadSnapshotRoot(db)
346347
blockNumber = math.MaxUint64
@@ -375,17 +376,9 @@ func inspectTrie(ctx *cli.Context) error {
375376
}
376377
fmt.Printf("ReadBlockHeader, root: %v, blocknum: %v\n", trieRootHash, blockNumber)
377378

378-
dbScheme := rawdb.ReadStateScheme(db)
379-
var config *trie.Config
380-
if dbScheme == rawdb.PathScheme {
381-
config = &trie.Config{
382-
PathDB: pathdb.ReadOnly,
383-
}
384-
} else if dbScheme == rawdb.HashScheme {
385-
config = trie.HashDefaults
386-
}
379+
triedb := utils.MakeTrieDatabase(ctx, db, false, true, false)
380+
defer triedb.Close()
387381

388-
triedb := trie.NewDatabase(db, config)
389382
theTrie, err := trie.New(trie.TrieID(trieRootHash), triedb)
390383
if err != nil {
391384
fmt.Printf("fail to new trie tree, err: %v, rootHash: %v\n", err, trieRootHash.String())

trie/inspect_trie.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import (
1414
"github.com/ethereum/go-ethereum/core/types"
1515
"github.com/ethereum/go-ethereum/log"
1616
"github.com/ethereum/go-ethereum/rlp"
17+
"github.com/ethereum/go-ethereum/triedb/database"
1718
"github.com/olekukonko/tablewriter"
1819
"golang.org/x/sync/semaphore"
1920
)
2021

2122
type Inspector struct {
2223
trie *Trie // traverse trie
23-
db *Database
24+
db database.NodeDatabase
2425
stateRootHash common.Hash
2526
blocknum uint64
2627
root node // root of triedb
@@ -95,7 +96,7 @@ func (trieStat *trieTreeStat) Display(ownerAddress string, treeType string) stri
9596
}
9697

9798
// NewInspector return an inspector obj
98-
func NewInspector(tr *Trie, db *Database, stateRootHash common.Hash, blocknum uint64, jobnum uint64) (*Inspector, error) {
99+
func NewInspector(tr *Trie, db database.NodeDatabase, stateRootHash common.Hash, blocknum uint64, jobnum uint64) (*Inspector, error) {
99100
if tr == nil {
100101
return nil, errors.New("trie is nil")
101102
}

0 commit comments

Comments
 (0)