2020-08-19 11:46:20 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/core/rawdb"
|
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
2020-08-19 11:46:20 +00:00
|
|
|
)
|
|
|
|
|
2021-07-28 02:47:38 +00:00
|
|
|
func NewBlockGetter(tx kv.Tx) *blockGetter {
|
2021-03-30 09:53:54 +00:00
|
|
|
return &blockGetter{tx}
|
2020-08-19 11:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type blockGetter struct {
|
2021-07-28 02:47:38 +00:00
|
|
|
tx kv.Tx
|
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) {
|
2021-05-01 07:42:23 +00:00
|
|
|
return rawdb.ReadBlockByHash(g.tx, hash)
|
2020-08-19 11:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *blockGetter) GetBlock(hash common.Hash, number uint64) *types.Block {
|
2021-05-01 07:42:23 +00:00
|
|
|
return rawdb.ReadBlock(g.tx, hash, number)
|
2020-08-19 11:46:20 +00:00
|
|
|
}
|