Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix inspect database error #2484

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading