This commit is contained in:
Roy Crihfield 2023-09-26 18:22:48 +08:00
parent 06fb10e209
commit e16e587d2b

View File

@ -90,11 +90,11 @@ func NewLvlDBReader(conf LvLDBReaderConfig) (*LvlDBReader, error) {
func (ldr *LvlDBReader) GetBlockByHash(hash common.Hash) (*types.Block, error) { func (ldr *LvlDBReader) GetBlockByHash(hash common.Hash) (*types.Block, error) {
height := rawdb.ReadHeaderNumber(ldr.ethDB, hash) height := rawdb.ReadHeaderNumber(ldr.ethDB, hash)
if height == nil { if height == nil {
return nil, fmt.Errorf("unable to read header height for header hash %s", hash.String()) return nil, fmt.Errorf("unable to read header height for header hash %s", hash)
} }
block := rawdb.ReadBlock(ldr.ethDB, hash, *height) block := rawdb.ReadBlock(ldr.ethDB, hash, *height)
if block == nil { if block == nil {
return nil, fmt.Errorf("unable to read block at height %d hash %s", *height, hash.String()) return nil, fmt.Errorf("unable to read block at height %d hash %s", *height, hash)
} }
return block, nil return block, nil
} }
@ -103,7 +103,7 @@ func (ldr *LvlDBReader) GetBlockByNumber(number uint64) (*types.Block, error) {
hash := rawdb.ReadCanonicalHash(ldr.ethDB, number) hash := rawdb.ReadCanonicalHash(ldr.ethDB, number)
block := rawdb.ReadBlock(ldr.ethDB, hash, number) block := rawdb.ReadBlock(ldr.ethDB, hash, number)
if block == nil { if block == nil {
return nil, fmt.Errorf("unable to read block at height %d hash %s", number, hash.String()) return nil, fmt.Errorf("unable to read block at height %d hash %s", number, hash)
} }
return block, nil return block, nil
} }
@ -112,11 +112,11 @@ func (ldr *LvlDBReader) GetBlockByNumber(number uint64) (*types.Block, error) {
func (ldr *LvlDBReader) GetReceiptsByHash(hash common.Hash) (types.Receipts, error) { func (ldr *LvlDBReader) GetReceiptsByHash(hash common.Hash) (types.Receipts, error) {
number := rawdb.ReadHeaderNumber(ldr.ethDB, hash) number := rawdb.ReadHeaderNumber(ldr.ethDB, hash)
if number == nil { if number == nil {
return nil, fmt.Errorf("unable to read header height for header hash %s", hash.String()) return nil, fmt.Errorf("unable to read header height for header hash %s", hash)
} }
receipts := rawdb.ReadReceipts(ldr.ethDB, hash, *number, ldr.chainConfig) receipts := rawdb.ReadReceipts(ldr.ethDB, hash, *number, ldr.chainConfig)
if receipts == nil { if receipts == nil {
return nil, fmt.Errorf("unable to read receipts at height %d hash %s", number, hash.String()) return nil, fmt.Errorf("unable to read receipts at height %d hash %s", number, hash)
} }
return receipts, nil return receipts, nil
} }
@ -125,11 +125,11 @@ func (ldr *LvlDBReader) GetReceiptsByHash(hash common.Hash) (types.Receipts, err
func (ldr *LvlDBReader) GetTdByHash(hash common.Hash) (*big.Int, error) { func (ldr *LvlDBReader) GetTdByHash(hash common.Hash) (*big.Int, error) {
number := rawdb.ReadHeaderNumber(ldr.ethDB, hash) number := rawdb.ReadHeaderNumber(ldr.ethDB, hash)
if number == nil { if number == nil {
return nil, fmt.Errorf("unable to read header height for header hash %s", hash.String()) return nil, fmt.Errorf("unable to read header height for header hash %s", hash)
} }
td := rawdb.ReadTd(ldr.ethDB, hash, *number) td := rawdb.ReadTd(ldr.ethDB, hash, *number)
if td == nil { if td == nil {
return nil, fmt.Errorf("unable to read total difficulty at height %d hash %s", number, hash.String()) return nil, fmt.Errorf("unable to read total difficulty at height %d hash %s", number, hash)
} }
return td, nil return td, nil
} }