mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
limit number of blocks
This commit is contained in:
parent
e23025876f
commit
c02d29d8e4
2 changed files with 13 additions and 0 deletions
|
|
@ -1229,6 +1229,13 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
|
||||||
// Note, this function doesn't make any changes in the state/blockchain and is
|
// Note, this function doesn't make any changes in the state/blockchain and is
|
||||||
// useful to execute and retrieve values.
|
// useful to execute and retrieve values.
|
||||||
func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]blockResult, error) {
|
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")
|
||||||
|
} else if len(opts.BlockStateCalls) > maxMulticallBlocks {
|
||||||
|
// TODO return error code.
|
||||||
|
return nil, errors.New("invalid params")
|
||||||
|
}
|
||||||
if blockNrOrHash == nil {
|
if blockNrOrHash == nil {
|
||||||
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
|
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
|
||||||
blockNrOrHash = &n
|
blockNrOrHash = &n
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,12 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// maxMulticallBlocks is the maximum number of blocks that can be simulated
|
||||||
|
// in a single request.
|
||||||
|
maxMulticallBlocks = 256
|
||||||
|
)
|
||||||
|
|
||||||
// CallBatch is a batch of calls to be simulated sequentially.
|
// CallBatch is a batch of calls to be simulated sequentially.
|
||||||
type CallBatch struct {
|
type CallBatch struct {
|
||||||
BlockOverrides *BlockOverrides
|
BlockOverrides *BlockOverrides
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue