Merge pull request #711 from gzliudan/fix-st1012

XDPoSChain, ethclient: fix staticcheck warning ST1012: rename NotFound to ErrNotFound
This commit is contained in:
Daniel Liu 2024-10-30 21:07:33 +08:00 committed by GitHub
commit b4fe994eff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View file

@ -75,7 +75,7 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
var r []*types.Receipt
err := ec.c.CallContext(ctx, &r, "eth_getBlockReceipts", blockNrOrHash)
if err == nil && r == nil {
return nil, ethereum.NotFound
return nil, ethereum.ErrNotFound
}
return r, err
}
@ -92,7 +92,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
if err != nil {
return nil, err
} else if len(raw) == 0 {
return nil, ethereum.NotFound
return nil, ethereum.ErrNotFound
}
// Decode header and transactions.
var head *types.Header
@ -154,7 +154,7 @@ func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.He
var head *types.Header
err := ec.c.CallContext(ctx, &head, "eth_getBlockByHash", hash, false)
if err == nil && head == nil {
err = ethereum.NotFound
err = ethereum.ErrNotFound
}
return head, err
}
@ -165,7 +165,7 @@ func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.H
var head *types.Header
err := ec.c.CallContext(ctx, &head, "eth_getBlockByNumber", toBlockNumArg(number), false)
if err == nil && head == nil {
err = ethereum.NotFound
err = ethereum.ErrNotFound
}
return head, err
}
@ -195,7 +195,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
if err != nil {
return nil, false, err
} else if json == nil {
return nil, false, ethereum.NotFound
return nil, false, ethereum.ErrNotFound
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
return nil, false, errors.New("server returned transaction without signature")
}
@ -241,7 +241,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
err := ec.c.CallContext(ctx, &json, "eth_getTransactionByBlockHashAndIndex", blockHash, hexutil.Uint64(index))
if err == nil {
if json == nil {
return nil, ethereum.NotFound
return nil, ethereum.ErrNotFound
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
return nil, errors.New("server returned transaction without signature")
}
@ -257,7 +257,7 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*
err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash)
if err == nil {
if r == nil {
return nil, ethereum.NotFound
return nil, ethereum.ErrNotFound
}
}
return r, err
@ -268,7 +268,7 @@ func (ec *Client) GetTransactionReceiptResult(ctx context.Context, txHash common
result, err := ec.c.GetResultCallContext(ctx, &r, "eth_getTransactionReceipt", txHash)
if err == nil {
if r == nil {
return nil, nil, ethereum.NotFound
return nil, nil, ethereum.ErrNotFound
}
}
return r, result, err

View file

@ -26,8 +26,8 @@ import (
"github.com/XinFinOrg/XDPoSChain/core/types"
)
// NotFound is returned by API methods if the requested item does not exist.
var NotFound = errors.New("not found")
// ErrNotFound is returned by API methods if the requested item does not exist.
var ErrNotFound = errors.New("not found")
// TODO: move subscription to package event