erigon-pulse/turbo/adapter/block_getter.go
2021-03-30 12:53:54 +03:00

25 lines
613 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"
"github.com/ledgerwatch/turbo-geth/ethdb"
)
func NewBlockGetter(tx ethdb.Tx) *blockGetter {
return &blockGetter{tx}
}
type blockGetter struct {
tx ethdb.Tx
}
func (g *blockGetter) GetBlockByHash(hash common.Hash) (*types.Block, error) {
return rawdb.ReadBlockByHash(ethdb.NewRoTxDb(g.tx), hash)
}
func (g *blockGetter) GetBlock(hash common.Hash, number uint64) *types.Block {
return rawdb.ReadBlock(ethdb.NewRoTxDb(g.tx), hash, number)
}