erigon-pulse/turbo/adapter/block_getter.go
Alex Sharov 77a4b3305d
rawdb to return errors: part 1 (#1286)
* ReadBlockByNumber and ReadChainConfig return error

* Let's make rawdb package to return error. But by small steps.
High-level methods need to move first:

ReadBlockByNumber
ReadChainConfig
ReadBlockByHash
ReadHeaderByHash
WriteChainConfig
WriteDatabaseVersion
WriteBlock
DeleteTd
WriteTd
ReadTd
2020-10-24 07:57:09 +01:00

24 lines
590 B
Go

package adapter
import (
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/core/rawdb"
"github.com/ledgerwatch/turbo-geth/core/types"
)
func NewBlockGetter(dbReader rawdb.DatabaseReader) *blockGetter {
return &blockGetter{dbReader}
}
type blockGetter struct {
dbReader rawdb.DatabaseReader
}
func (g *blockGetter) GetBlockByHash(hash common.Hash) (*types.Block, error) {
return rawdb.ReadBlockByHash(g.dbReader, hash)
}
func (g *blockGetter) GetBlock(hash common.Hash, number uint64) *types.Block {
return rawdb.ReadBlock(g.dbReader, hash, number)
}