needed type assertion

This commit is contained in:
i-norden 2021-12-29 14:57:21 -06:00
parent 373d24e26b
commit 907c7132f4
2 changed files with 5 additions and 4 deletions

View File

@ -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")

View File

@ -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)
}