Skip to content

Commit

Permalink
fix: fix inspect database error (#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjunLi authored May 27, 2024
1 parent b014626 commit 05543e5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (frdb *freezerdb) SetBlockStore(block ethdb.Database) {
frdb.blockStore = block
}

func (frdb *freezerdb) HasSeparateBlockStore() bool {
return frdb.blockStore != nil
}

// Freeze is a helper method used for external testing to trigger and block until
// a freeze cycle completes, without having to sleep for a minute to trigger the
// automatic background run.
Expand Down Expand Up @@ -263,6 +267,10 @@ func (db *nofreezedb) SetBlockStore(block ethdb.Database) {
db.blockStore = block
}

func (db *nofreezedb) HasSeparateBlockStore() bool {
return db.blockStore != nil
}

func (db *nofreezedb) BlockStoreReader() ethdb.Reader {
if db.blockStore != nil {
return db.blockStore
Expand Down Expand Up @@ -769,7 +777,8 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
trieIter = db.StateStore().NewIterator(keyPrefix, nil)
defer trieIter.Release()
}
if db.BlockStore() != db {

if db.HasSeparateBlockStore() {
blockIter = db.BlockStore().NewIterator(keyPrefix, nil)
defer blockIter.Release()
}
Expand Down
4 changes: 4 additions & 0 deletions core/rawdb/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (t *table) SetBlockStore(block ethdb.Database) {
panic("not implement")
}

func (t *table) HasSeparateBlockStore() bool {
panic("not implement")
}

// NewTable returns a database object that prefixes all keys with a given string.
func NewTable(db ethdb.Database, prefix string) ethdb.Database {
return &table{
Expand Down
1 change: 1 addition & 0 deletions ethdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ type StateStoreReader interface {
type BlockStore interface {
BlockStore() Database
SetBlockStore(block Database)
HasSeparateBlockStore() bool
}

type BlockStoreReader interface {
Expand Down
4 changes: 4 additions & 0 deletions ethdb/remotedb/remotedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func (db *Database) BlockStore() ethdb.Database {
return db
}

func (db *Database) HasSeparateBlockStore() bool {
return false
}

func (db *Database) SetBlockStore(block ethdb.Database) {
panic("not supported")
}
Expand Down

0 comments on commit 05543e5

Please sign in to comment.