[ethereum/go-ethereum] Add AccountRangeAt to debug API (#17438)

jwasinger commented on this pull request.

> +type AccountRangeResult struct {
+ result []common.Address `json:»result»`
+}
+
+func accountRange(st state.Trie, start *common.Address, maxResult int) (AccountRangeResult, error) {
+ it := trie.NewIterator(st.NodeIterator(start[:]))
+ result := []common.Address{}
+ for i := 0; i < maxResult && it.Next(); i++ { + key := st.GetKey(it.Key) + if key == nil { + return AccountRangeResult{}, fmt.Errorf("no preimage found for hash %x", it.Key) + } + fmt.Println(common.BytesToAddress(key)) + result = append(result, common.BytesToAddress(key)) + } + return AccountRangeResult{result}, nil Somehow the results are not being passed back when I call this via rpc. I added some debug statements and got this (addresses and then `len(result)`): ``` [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 223] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 136] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 142] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 104] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 221] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 91] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 69] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 209] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 164] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 191] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 203] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 79] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 131] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 116] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 225] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 147] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 112] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 152] 20 ``` But when I try and access the method via `curl`: ``` > curl -X POST -H ‘Content-Type: application/json’ —data ‘{«jsonrpc»:»2.0″,»method»:»debug_accountRange»,»params»:[0, 0, «0x0000000000000000000000000000000000000000″, 20],»id»:1}’ localhost:8545

{«jsonrpc»:»2.0″,»id»:1,»result»:{}}
«`