Rename FilterOptions to BlockFilterArgs

This commit is contained in:
Taylor Gerring 2015-03-19 23:55:17 -04:00
parent d791fe4975
commit 3cea7d87c1
3 changed files with 15 additions and 15 deletions

View File

@ -406,7 +406,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case "eth_compileSolidity", "eth_compileLLL", "eth_compileSerpent": case "eth_compileSolidity", "eth_compileLLL", "eth_compileSerpent":
return NewNotImplementedError(req.Method) return NewNotImplementedError(req.Method)
case "eth_newFilter": case "eth_newFilter":
args := new(FilterOptions) args := new(BlockFilterArgs)
if err := json.Unmarshal(req.Params, &args); err != nil { if err := json.Unmarshal(req.Params, &args); err != nil {
return err return err
} }
@ -444,7 +444,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
} }
*reply = NewLogsRes(p.xeth().Logs(args.Id)) *reply = NewLogsRes(p.xeth().Logs(args.Id))
case "eth_getLogs": case "eth_getLogs":
args := new(FilterOptions) args := new(BlockFilterArgs)
if err := json.Unmarshal(req.Params, &args); err != nil { if err := json.Unmarshal(req.Params, &args); err != nil {
return err return err
} }
@ -561,7 +561,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return nil return nil
} }
func toFilterOptions(options *FilterOptions) *core.FilterOptions { func toFilterOptions(options *BlockFilterArgs) *core.FilterOptions {
var opts core.FilterOptions var opts core.FilterOptions
// Convert optional address slice/string to byte slice // Convert optional address slice/string to byte slice

View File

@ -433,7 +433,7 @@ func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
return nil return nil
} }
type FilterOptions struct { type BlockFilterArgs struct {
Earliest int64 Earliest int64
Latest int64 Latest int64
Address interface{} Address interface{}
@ -442,7 +442,7 @@ type FilterOptions struct {
Max int Max int
} }
func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) { func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
var obj []struct { var obj []struct {
FromBlock interface{} `json:"fromBlock"` FromBlock interface{} `json:"fromBlock"`
ToBlock interface{} `json:"toBlock"` ToBlock interface{} `json:"toBlock"`

View File

@ -388,7 +388,7 @@ func TestGetDataEmptyArgs(t *testing.T) {
} }
} }
func TestFilterOptions(t *testing.T) { func TestBlockFilterArgs(t *testing.T) {
input := `[{ input := `[{
"fromBlock": "0x1", "fromBlock": "0x1",
"toBlock": "0x2", "toBlock": "0x2",
@ -396,7 +396,7 @@ func TestFilterOptions(t *testing.T) {
"offset": "0x0", "offset": "0x0",
"address": "0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", "address": "0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8",
"topics": ["0x12341234"]}]` "topics": ["0x12341234"]}]`
expected := new(FilterOptions) expected := new(BlockFilterArgs)
expected.Earliest = 1 expected.Earliest = 1
expected.Latest = 2 expected.Latest = 2
expected.Max = 3 expected.Max = 3
@ -404,7 +404,7 @@ func TestFilterOptions(t *testing.T) {
expected.Address = "0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8" expected.Address = "0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"
// expected.Topics = []string{"0x12341234"} // expected.Topics = []string{"0x12341234"}
args := new(FilterOptions) args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil { if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err) t.Error(err)
} }
@ -434,16 +434,16 @@ func TestFilterOptions(t *testing.T) {
// } // }
} }
func TestFilterOptionsWords(t *testing.T) { func TestBlockFilterArgsWords(t *testing.T) {
input := `[{ input := `[{
"fromBlock": "latest", "fromBlock": "latest",
"toBlock": "pending" "toBlock": "pending"
}]` }]`
expected := new(FilterOptions) expected := new(BlockFilterArgs)
expected.Earliest = 0 expected.Earliest = 0
expected.Latest = -1 expected.Latest = -1
args := new(FilterOptions) args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil { if err := json.Unmarshal([]byte(input), &args); err != nil {
t.Error(err) t.Error(err)
} }
@ -457,13 +457,13 @@ func TestFilterOptionsWords(t *testing.T) {
} }
} }
func TestFilterOptionsNums(t *testing.T) { func TestBlockFilterArgsNums(t *testing.T) {
input := `[{ input := `[{
"fromBlock": 2, "fromBlock": 2,
"toBlock": 3 "toBlock": 3
}]` }]`
args := new(FilterOptions) args := new(BlockFilterArgs)
err := json.Unmarshal([]byte(input), &args) err := json.Unmarshal([]byte(input), &args)
switch err.(type) { switch err.(type) {
case *DecodeParamError: case *DecodeParamError:
@ -474,10 +474,10 @@ func TestFilterOptionsNums(t *testing.T) {
} }
func TestFilterOptionsEmptyArgs(t *testing.T) { func TestBlockFilterArgsEmptyArgs(t *testing.T) {
input := `[]` input := `[]`
args := new(FilterOptions) args := new(BlockFilterArgs)
err := json.Unmarshal([]byte(input), &args) err := json.Unmarshal([]byte(input), &args)
if err == nil { if err == nil {
t.Error("Expected error but didn't get one") t.Error("Expected error but didn't get one")