From 907c7132f41f98f14572573bb8767d93f8f14a0f Mon Sep 17 00:00:00 2001 From: i-norden Date: Wed, 29 Dec 2021 14:57:21 -0600 Subject: [PATCH] needed type assertion --- cmd/validate.go | 6 +++--- pkg/eth/backend.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/validate.go b/cmd/validate.go index c91fb918..1fcd5a82 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -63,12 +63,12 @@ func validate() { ExpiryDuration: time.Minute * time.Duration(CacheExpiryInMins), }) - validator := validator.NewValidator(nil, ethDB) - if err = validator.ValidateTrie(stateRoot); err != nil { + val := validator.NewValidator(nil, ethDB) + if err = val.ValidateTrie(stateRoot); err != nil { log.Fatalln("Error validating state root") } - stats := ethDB.GetCacheStats() + stats := ethDB.(*ipfsethdb.Database).GetCacheStats() log.Debugf("groupcache stats %+v", stats) log.Infoln("Successfully validated state root") diff --git a/pkg/eth/backend.go b/pkg/eth/backend.go index 1e1445f3..3d9485a4 100644 --- a/pkg/eth/backend.go +++ b/pkg/eth/backend.go @@ -130,7 +130,7 @@ func NewEthBackend(db *postgres.DB, c *Config) (*Backend, error) { ExpiryDuration: time.Minute * time.Duration(gcc.StateDB.CacheExpiryInMins), }) - logStateDBStatsOnTimer(ethDB, gcc) + logStateDBStatsOnTimer(ethDB.(*ipfsethdb.Database), gcc) return &Backend{ DB: db, @@ -825,6 +825,7 @@ func (b *Backend) GetHeader(hash common.Hash, height uint64) *types.Header { return header } +// ValidateTrie validates the trie for the given stateRoot func (b *Backend) ValidateTrie(stateRoot common.Hash) error { return validator.NewValidator(nil, b.EthDB).ValidateTrie(stateRoot) }