2018-05-02 16:17:02 +00:00
|
|
|
package level
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Reader interface {
|
|
|
|
GetBlock(hash common.Hash, number uint64) *types.Block
|
2018-05-03 21:58:45 +00:00
|
|
|
GetBlockNumber(hash common.Hash) uint64
|
2018-05-02 16:17:02 +00:00
|
|
|
GetBlockReceipts(hash common.Hash, number uint64) types.Receipts
|
|
|
|
GetCanonicalHash(number uint64) common.Hash
|
2018-05-03 21:58:45 +00:00
|
|
|
GetHeadBlockHash() common.Hash
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LevelDatabaseReader struct {
|
2018-05-03 21:58:45 +00:00
|
|
|
reader core.DatabaseReader
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewLevelDatabaseReader(reader core.DatabaseReader) *LevelDatabaseReader {
|
2018-05-03 21:58:45 +00:00
|
|
|
return &LevelDatabaseReader{reader: reader}
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ldbr *LevelDatabaseReader) GetBlock(hash common.Hash, number uint64) *types.Block {
|
2018-05-03 21:58:45 +00:00
|
|
|
return core.GetBlock(ldbr.reader, hash, number)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ldbr *LevelDatabaseReader) GetBlockNumber(hash common.Hash) uint64 {
|
|
|
|
return core.GetBlockNumber(ldbr.reader, hash)
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ldbr *LevelDatabaseReader) GetBlockReceipts(hash common.Hash, number uint64) types.Receipts {
|
2018-05-03 21:58:45 +00:00
|
|
|
return core.GetBlockReceipts(ldbr.reader, hash, number)
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ldbr *LevelDatabaseReader) GetCanonicalHash(number uint64) common.Hash {
|
2018-05-03 21:58:45 +00:00
|
|
|
return core.GetCanonicalHash(ldbr.reader, number)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ldbr *LevelDatabaseReader) GetHeadBlockHash() common.Hash {
|
|
|
|
return core.GetHeadBlockHash(ldbr.reader)
|
2018-05-02 16:17:02 +00:00
|
|
|
}
|