From c7dc379da5a02fb8ac92788fa317379fbde00d20 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 10:14:52 +0100 Subject: GetBlockByHashArgs --- rpc/api.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index aa5b54199..8d1a412d1 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -245,7 +245,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.Hash) + block := api.xeth().EthBlockByHexstring(args.Hash) br := NewBlockRes(block) br.fullTx = true @@ -273,14 +273,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash)) + br := NewBlockRes(api.xeth().EthBlockByHexstring(args.Hash)) if args.Index > int64(len(br.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") } uhash := br.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) *reply = uncle case "eth_getUncleByBlockNumberAndIndex": @@ -298,7 +298,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } uhash := v.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) *reply = uncle case "eth_getCompilers": -- cgit v1.2.3 From 966cfa4bddb0fbe355dadb83541325a3b5c132f8 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 10:34:21 +0100 Subject: NewTxArgs --- rpc/api.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index 8d1a412d1..b5f759711 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -185,11 +185,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - if err := args.requirements(); err != nil { - return err - } - - v, err := api.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) + v, err := api.xeth().Transact(args.From.Hex(), args.To.Hex(), args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) if err != nil { return err } @@ -200,7 +196,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - v, err := api.xethAtStateNum(args.BlockNumber).Call(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) + v, err := api.xethAtStateNum(args.BlockNumber).Call(args.From.Hex(), args.To.Hex(), args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) if err != nil { return err } -- cgit v1.2.3 From bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 10:52:32 +0100 Subject: GetStorageArgs --- rpc/api.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index b5f759711..f5ce8acb6 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -106,11 +106,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - if err := args.requirements(); err != nil { - return err - } - - *reply = api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Storage() + *reply = api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()).Storage() case "eth_getStorageAt": args := new(GetStorageAtArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit v1.2.3 From 9c4504dc41bbedb590db20519030224df66ce4b1 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 12:11:28 +0100 Subject: GetStorageAtArgs --- rpc/api.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index f5ce8acb6..10d2e529e 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -112,12 +112,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - if err := args.requirements(); err != nil { - return err - } - state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address) - value := state.StorageString(args.Key) + state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()) + value := state.StorageString(args.Key.Hex()) *reply = common.Bytes2Hex(value.Bytes()) case "eth_getTransactionCount": -- cgit v1.2.3 From 4523a00b91dbe98c6cb03acef362c5592973bcd3 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 12:47:00 +0100 Subject: GetTxCountArgs --- rpc/api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index 10d2e529e..6f3e78cc0 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -123,12 +123,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - err := args.requirements() - if err != nil { - return err - } - - *reply = api.xethAtStateNum(args.BlockNumber).TxCountAt(args.Address) + *reply = api.xethAtStateNum(args.BlockNumber).TxCountAt(args.Address.Hex()) case "eth_getBlockTransactionCountByHash": args := new(GetBlockByHashArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit v1.2.3 From c139af582663d760f58e7b50dcb9f355c47ef47e Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 13:10:31 +0100 Subject: GetBalanceArgs --- rpc/api.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index 6f3e78cc0..aba47eee2 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -94,11 +94,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - if err := args.requirements(); err != nil { - return err - } - - v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance() + v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()).Balance() *reply = common.ToHex(v.Bytes()) case "eth_getStorage", "eth_storageAt": args := new(GetStorageArgs) -- cgit v1.2.3 From cd6b3fd28a0624ac27cecf9f3e331a027b9c7e67 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 13:50:22 +0100 Subject: GetDataArgs --- rpc/api.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index aba47eee2..0f5bac657 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -159,10 +159,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - if err := args.requirements(); err != nil { - return err - } - *reply = api.xethAtStateNum(args.BlockNumber).CodeAt(args.Address) + *reply = api.xethAtStateNum(args.BlockNumber).CodeAt(args.Address.Hex()) case "eth_sendTransaction", "eth_transact": args := new(NewTxArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit v1.2.3 From 3472823be94acc5b999dcb8741901b3e0c07f5d6 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 14:17:32 +0100 Subject: HashIndexArgs --- rpc/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index 0f5bac657..ff166264b 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -212,7 +212,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { } - tx := api.xeth().EthTransactionByHash(args.Hash) + tx := api.xeth().EthTransactionByHash(args.Hash.Hex()) if tx != nil { *reply = NewTransactionRes(tx) } @@ -222,7 +222,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHexstring(args.Hash) + block := api.xeth().EthBlockByHash(args.Hash) br := NewBlockRes(block) br.fullTx = true @@ -250,7 +250,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - br := NewBlockRes(api.xeth().EthBlockByHexstring(args.Hash)) + br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash)) if args.Index > int64(len(br.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") -- cgit v1.2.3 From 62ebf999bf71ef05e34e234b6e07cc31188970b7 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 20:04:03 +0100 Subject: FilterStringArgs tests --- rpc/api.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index ff166264b..bde24847f 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -297,10 +297,6 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - if err := args.requirements(); err != nil { - return err - } - id := api.xeth().NewFilterString(args.Word) *reply = common.ToHex(big.NewInt(int64(id)).Bytes()) case "eth_uninstallFilter": -- cgit v1.2.3 From 9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 20:52:09 +0100 Subject: WhisperFilterArgs --- rpc/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index bde24847f..ad48b8607 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -417,7 +417,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } opts := new(xeth.Options) - opts.From = args.From + // opts.From = args.From opts.To = args.To opts.Topics = args.Topics id := api.xeth().NewWhisperFilter(opts) -- cgit v1.2.3 From 49a912ce33274f60659ddb3af7e3fec89ee1b59e Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 22:14:31 +0100 Subject: Undo xeth changes --- rpc/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index ad48b8607..4ae0ff668 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -212,7 +212,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { } - tx := api.xeth().EthTransactionByHash(args.Hash.Hex()) + tx := api.xeth().EthTransactionByHash(args.Hash) if tx != nil { *reply = NewTransactionRes(tx) } @@ -257,7 +257,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } uhash := br.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) *reply = uncle case "eth_getUncleByBlockNumberAndIndex": @@ -275,7 +275,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } uhash := v.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) *reply = uncle case "eth_getCompilers": -- cgit v1.2.3 From 2c5a32ebbc60f23e609c8397dad5d09ee38b69bb Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 22:24:48 +0100 Subject: Undo XEth changes --- rpc/api.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index ad48b8607..339de4432 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -126,7 +126,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := NewBlockRes(api.xeth().EthBlockByHash(args.BlockHash)) + block := NewBlockRes(api.xeth().EthBlockByHash(args.BlockHash.Hex())) *reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes()) case "eth_getBlockTransactionCountByNumber": args := new(GetBlockByNumberArgs) @@ -142,7 +142,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.BlockHash) + block := api.xeth().EthBlockByHash(args.BlockHash.Hex()) br := NewBlockRes(block) *reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes()) case "eth_getUncleCountByBlockNumber": @@ -191,7 +191,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.BlockHash) + block := api.xeth().EthBlockByHash(args.BlockHash.Hex()) br := NewBlockRes(block) br.fullTx = args.IncludeTxs @@ -222,7 +222,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.Hash) + block := api.xeth().EthBlockByHash(args.Hash.Hex()) br := NewBlockRes(block) br.fullTx = true @@ -250,14 +250,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash)) + br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash.Hex())) if args.Index > int64(len(br.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") } uhash := br.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) *reply = uncle case "eth_getUncleByBlockNumberAndIndex": @@ -275,7 +275,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err } uhash := v.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHexstring(uhash)) + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) *reply = uncle case "eth_getCompilers": -- cgit v1.2.3 From bb12dbe233db2e064715b329b7ba987c76ba3bfa Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 22:35:42 +0100 Subject: Prefer args as strings not objects --- rpc/api.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index cdd95c888..76fa9b9df 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -94,7 +94,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()).Balance() + v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance() *reply = common.ToHex(v.Bytes()) case "eth_getStorage", "eth_storageAt": args := new(GetStorageArgs) @@ -102,15 +102,15 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - *reply = api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()).Storage() + *reply = api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Storage() case "eth_getStorageAt": args := new(GetStorageAtArgs) if err := json.Unmarshal(req.Params, &args); err != nil { return err } - state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address.Hex()) - value := state.StorageString(args.Key.Hex()) + state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address) + value := state.StorageString(args.Key) *reply = common.Bytes2Hex(value.Bytes()) case "eth_getTransactionCount": @@ -119,14 +119,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - *reply = api.xethAtStateNum(args.BlockNumber).TxCountAt(args.Address.Hex()) + *reply = api.xethAtStateNum(args.BlockNumber).TxCountAt(args.Address) case "eth_getBlockTransactionCountByHash": args := new(GetBlockByHashArgs) if err := json.Unmarshal(req.Params, &args); err != nil { return err } - block := NewBlockRes(api.xeth().EthBlockByHash(args.BlockHash.Hex())) + block := NewBlockRes(api.xeth().EthBlockByHash(args.BlockHash)) *reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes()) case "eth_getBlockTransactionCountByNumber": args := new(GetBlockByNumberArgs) @@ -142,7 +142,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.BlockHash.Hex()) + block := api.xeth().EthBlockByHash(args.BlockHash) br := NewBlockRes(block) *reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes()) case "eth_getUncleCountByBlockNumber": @@ -159,14 +159,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - *reply = api.xethAtStateNum(args.BlockNumber).CodeAt(args.Address.Hex()) + *reply = api.xethAtStateNum(args.BlockNumber).CodeAt(args.Address) case "eth_sendTransaction", "eth_transact": args := new(NewTxArgs) if err := json.Unmarshal(req.Params, &args); err != nil { return err } - v, err := api.xeth().Transact(args.From.Hex(), args.To.Hex(), args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) + v, err := api.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) if err != nil { return err } @@ -177,7 +177,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - v, err := api.xethAtStateNum(args.BlockNumber).Call(args.From.Hex(), args.To.Hex(), args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) + v, err := api.xethAtStateNum(args.BlockNumber).Call(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) if err != nil { return err } @@ -191,7 +191,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.BlockHash.Hex()) + block := api.xeth().EthBlockByHash(args.BlockHash) br := NewBlockRes(block) br.fullTx = args.IncludeTxs @@ -222,7 +222,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - block := api.xeth().EthBlockByHash(args.Hash.Hex()) + block := api.xeth().EthBlockByHash(args.Hash) br := NewBlockRes(block) br.fullTx = true @@ -250,14 +250,14 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash.Hex())) + br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash)) if args.Index > int64(len(br.Uncles)) || args.Index < 0 { return NewValidationError("Index", "does not exist") } - uhash := br.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) + uhash := br.Uncles[args.Index] + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.Hex())) *reply = uncle case "eth_getUncleByBlockNumberAndIndex": @@ -274,8 +274,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return NewValidationError("Index", "does not exist") } - uhash := v.Uncles[args.Index].Hex() - uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash)) + uhash := v.Uncles[args.Index] + uncle := NewBlockRes(api.xeth().EthBlockByHash(uhash.Hex())) *reply = uncle case "eth_getCompilers": @@ -332,7 +332,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - *reply = api.xeth().RemoteMining().SubmitWork(args.Nonce, args.Digest, args.Header) + *reply = api.xeth().RemoteMining().SubmitWork(args.Nonce, common.HexToHash(args.Digest), common.HexToHash(args.Header)) case "db_putString": args := new(DbArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit v1.2.3 From 9f84c78eb5cceb5f413fbdeafe63786f1b958e83 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 27 Mar 2015 15:54:54 +0100 Subject: BlockFilterArgs --- rpc/api.go | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index 76fa9b9df..534b6fc5d 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -471,42 +471,29 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err func toFilterOptions(options *BlockFilterArgs) *core.FilterOptions { var opts core.FilterOptions - // Convert optional address slice/string to byte slice - if str, ok := options.Address.(string); ok { - opts.Address = []common.Address{common.HexToAddress(str)} - } else if slice, ok := options.Address.([]interface{}); ok { - bslice := make([]common.Address, len(slice)) - for i, addr := range slice { - if saddr, ok := addr.(string); ok { - bslice[i] = common.HexToAddress(saddr) - } - } - opts.Address = bslice - } + opts.Address = cAddress(options.Address) + opts.Topics = cTopics(options.Topics) opts.Earliest = options.Earliest opts.Latest = options.Latest - topics := make([][]common.Hash, len(options.Topics)) - for i, topicDat := range options.Topics { - if slice, ok := topicDat.([]interface{}); ok { - topics[i] = make([]common.Hash, len(slice)) - for j, topic := range slice { - topics[i][j] = common.HexToHash(topic.(string)) - } - } else if str, ok := topicDat.(string); ok { - topics[i] = []common.Hash{common.HexToHash(str)} - } - } - opts.Topics = topics - return &opts } -/* - Work() chan<- *types.Block - SetWorkCh(chan<- Work) - Stop() - Start() - Rate() uint64 -*/ +func cAddress(a []string) []common.Address { + bslice := make([]common.Address, len(a)) + for i, addr := range a { + bslice[i] = common.HexToAddress(addr) + } + return bslice +} + +func cTopics(t [][]string) [][]common.Hash { + topics := make([][]common.Hash, len(t)) + for i, iv := range t { + for j, jv := range iv { + topics[i][j] = common.HexToHash(jv) + } + } + return topics +} -- cgit v1.2.3 From 43d521e90e9516429dd0499ff88bf3f37ec78c48 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 27 Mar 2015 16:36:01 +0100 Subject: Decouple core from rpc --- rpc/api.go | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) (limited to 'rpc/api.go') diff --git a/rpc/api.go b/rpc/api.go index f755f07bd..8803c28dd 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -6,7 +6,6 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/xeth" ) @@ -277,8 +276,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - opts := toFilterOptions(args) - id := api.xeth().RegisterFilter(opts) + id := api.xeth().RegisterFilter(args.Earliest, args.Latest, args.Skip, args.Max, args.Address, args.Topics) *reply = common.ToHex(big.NewInt(int64(id)).Bytes()) case "eth_newBlockFilter": args := new(FilterStringArgs) @@ -310,8 +308,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err := json.Unmarshal(req.Params, &args); err != nil { return err } - opts := toFilterOptions(args) - *reply = NewLogsRes(api.xeth().AllLogs(opts)) + *reply = NewLogsRes(api.xeth().AllLogs(args.Earliest, args.Latest, args.Skip, args.Max, args.Address, args.Topics)) case "eth_getWork": api.xeth().SetMining(true) *reply = api.xeth().RemoteMining().GetWork() @@ -456,33 +453,3 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err rpclogger.DebugDetailf("Reply: %T %s", reply, reply) return nil } - -func toFilterOptions(options *BlockFilterArgs) *core.FilterOptions { - var opts core.FilterOptions - - opts.Address = cAddress(options.Address) - opts.Topics = cTopics(options.Topics) - - opts.Earliest = options.Earliest - opts.Latest = options.Latest - - return &opts -} - -func cAddress(a []string) []common.Address { - bslice := make([]common.Address, len(a)) - for i, addr := range a { - bslice[i] = common.HexToAddress(addr) - } - return bslice -} - -func cTopics(t [][]string) [][]common.Hash { - topics := make([][]common.Hash, len(t)) - for i, iv := range t { - for j, jv := range iv { - topics[i][j] = common.HexToHash(jv) - } - } - return topics -} -- cgit v1.2.3