diff --git a/core/rawdb/database.go b/core/rawdb/database.go index a0e3147f2a..29c70e6961 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -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. @@ -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 @@ -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() } diff --git a/core/rawdb/table.go b/core/rawdb/table.go index 2dab09f869..c4a029bcad 100644 --- a/core/rawdb/table.go +++ b/core/rawdb/table.go @@ -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{ diff --git a/ethdb/database.go b/ethdb/database.go index daff198e32..e4bfbc95bc 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -183,6 +183,7 @@ type StateStoreReader interface { type BlockStore interface { BlockStore() Database SetBlockStore(block Database) + HasSeparateBlockStore() bool } type BlockStoreReader interface { diff --git a/ethdb/remotedb/remotedb.go b/ethdb/remotedb/remotedb.go index 18890f2227..2ba5807a32 100644 --- a/ethdb/remotedb/remotedb.go +++ b/ethdb/remotedb/remotedb.go @@ -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") }