mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
add error code for blocks length check
This commit is contained in:
parent
c02d29d8e4
commit
e4eb56a4a9
2 changed files with 7 additions and 4 deletions
|
|
@ -1230,11 +1230,9 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
|
|||
// useful to execute and retrieve values.
|
||||
func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]blockResult, error) {
|
||||
if len(opts.BlockStateCalls) == 0 {
|
||||
// TODO return error code.
|
||||
return nil, errors.New("invalid params")
|
||||
return nil, &invalidParamsError{message: "empty input"}
|
||||
} else if len(opts.BlockStateCalls) > maxMulticallBlocks {
|
||||
// TODO return error code.
|
||||
return nil, errors.New("invalid params")
|
||||
return nil, &invalidParamsError{message: "too many blocks"}
|
||||
}
|
||||
if blockNrOrHash == nil {
|
||||
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
|
||||
|
|
|
|||
|
|
@ -68,3 +68,8 @@ func callErrorFromError(err error) *callError {
|
|||
Code: errCodeInternalError,
|
||||
}
|
||||
}
|
||||
|
||||
type invalidParamsError struct{ message string }
|
||||
|
||||
func (e *invalidParamsError) Error() string { return e.message }
|
||||
func (e *invalidParamsError) ErrorCode() int { return errCodeInvalidParams }
|
||||
|
|
|
|||
Loading…
Reference in a new issue