eth: address some concerns (squash this)

This commit is contained in:
Jared Wasinger 2019-03-18 12:31:32 -07:00 committed by Guillaume Ballet
parent 3dd262f59d
commit a37395332c

View file

@ -19,8 +19,8 @@ package eth
import ( import (
"compress/gzip" "compress/gzip"
"context" "context"
"errors"
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"io" "io"
"math/big" "math/big"
@ -363,11 +363,19 @@ func accountRange(st state.Trie, start *common.Address, maxResult int) (AccountR
return result, nil return result, nil
} }
// enumerate all accounts in the latest state const (
AccountRangeAtMaxResults = 256
)
// AccountRangeAt enumerates all accounts in the latest state
func (api *PrivateDebugAPI) AccountRangeAt(ctx context.Context, startAddr *common.Address, maxResults int) (AccountRangeResult, error) { func (api *PrivateDebugAPI) AccountRangeAt(ctx context.Context, startAddr *common.Address, maxResults int) (AccountRangeResult, error) {
var statedb *state.StateDB = nil var statedb *state.StateDB
var err error = nil var err error
var block = api.eth.blockchain.CurrentBlock() block := api.eth.blockchain.CurrentBlock()
if maxResults > AccountRangeAtMaxResults {
maxResults = AccountRangeAtMaxResults
}
if len(block.Transactions()) == 0 { if len(block.Transactions()) == 0 {
parent := api.eth.blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1) parent := api.eth.blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1)