2020-08-19 11:46:20 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/core/rawdb"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
2020-11-22 21:25:26 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2020-08-19 11:46:20 +00:00
|
|
|
)
|
|
|
|
|
2020-11-22 21:25:26 +00:00
|
|
|
func NewBlockGetter(dbReader ethdb.Database) *blockGetter {
|
2020-08-19 11:46:20 +00:00
|
|
|
return &blockGetter{dbReader}
|
|
|
|
}
|
|
|
|
|
|
|
|
type blockGetter struct {
|
2020-11-22 21:25:26 +00:00
|
|
|
dbReader ethdb.Database
|
2020-08-19 11:46:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 06:57:09 +00:00
|
|
|
func (g *blockGetter) GetBlockByHash(hash common.Hash) (*types.Block, error) {
|
2020-08-19 11:46:20 +00:00
|
|
|
return rawdb.ReadBlockByHash(g.dbReader, hash)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *blockGetter) GetBlock(hash common.Hash, number uint64) *types.Block {
|
|
|
|
return rawdb.ReadBlock(g.dbReader, hash, number)
|
|
|
|
}
|