Skip to content

Commit

Permalink
les: return error for missing header also in les backend - StateAndHe…
Browse files Browse the repository at this point in the history
…aderByNumber
  • Loading branch information
holiman authored and fjl committed May 2, 2019
1 parent 753e74c commit f078909
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion les/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package les

import (
"context"
"errors"
"math/big"

"github.com/ethereum/go-ethereum/accounts"
Expand Down Expand Up @@ -78,9 +79,12 @@ func (b *LesApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumb

func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error) {
header, err := b.HeaderByNumber(ctx, blockNr)
if header == nil || err != nil {
if err != nil {
return nil, nil, err
}
if header == nil {
return nil, nil, errors.New("header not found")
}
return light.NewState(ctx, header, b.eth.odr), header, nil
}

Expand Down

0 comments on commit f078909

Please sign in to comment.