From 6cc02aadbff9c37cc623fadb21029527a11a06f4 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 19:58:59 -0400 Subject: Inline getStateWithNum --- rpc/api.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index d00b86ac0..7fc8f32e2 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -81,10 +81,6 @@ func (self *EthereumApi) xethWithStateNum(num int64) *xeth.XEth { return self.xeth().WithState(st) } -func (self *EthereumApi) getStateWithNum(num int64) *xeth.State { - return self.xethWithStateNum(num).State() -} - func (self *EthereumApi) start() { timer := time.NewTicker(filterTickerTime) done: @@ -290,8 +286,7 @@ func (p *EthereumApi) GetBalance(args *GetBalanceArgs, reply *interface{}) error if err := args.requirements(); err != nil { return err } - state := p.getStateWithNum(args.BlockNumber).SafeGet(args.Address) - *reply = common.ToHex(state.Balance().Bytes()) + *reply = common.ToHex(p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance().Bytes()) return nil } @@ -299,7 +294,7 @@ func (p *EthereumApi) GetStorage(args *GetStorageArgs, reply *interface{}) error if err := args.requirements(); err != nil { return err } - *reply = p.getStateWithNum(args.BlockNumber).SafeGet(args.Address).Storage() + *reply = p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Storage() return nil } @@ -307,9 +302,10 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e if err := args.requirements(); err != nil { return err } - state := p.getStateWithNum(args.BlockNumber).SafeGet(args.Address) + state := p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address) value := state.StorageString(args.Key) + var hx string if strings.Index(args.Key, "0x") == 0 { hx = string([]byte(args.Key)[2:]) -- cgit From b7745c683529bc60139d4af7fec2bf849928bfe7 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:00:18 -0400 Subject: inline HasWhisperIdentity --- rpc/api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 7fc8f32e2..54efd6005 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -416,11 +416,6 @@ func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{}) return nil } -func (p *EthereumApi) HasWhisperIdentity(args string, reply *interface{}) error { - *reply = p.xeth().Whisper().HasIdentity(args) - return nil -} - func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error { *reply = p.xeth().Whisper().Messages(id) return nil @@ -763,7 +758,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.HasWhisperIdentity(args.Identity, reply) + *reply = p.xeth().Whisper().HasIdentity(args.Identity) case "shh_newGroup", "shh_addToGroup": return NewNotImplementedError(req.Method) case "shh_newFilter": -- cgit From 7562bc1dbc23b0b8a384de29729ea24daa5c45a0 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:00:41 -0400 Subject: inline GetBalance --- rpc/api.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 54efd6005..5654ee3d3 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -282,14 +282,6 @@ func (p *EthereumApi) Call(args *NewTxArgs, reply *interface{}) error { return nil } -func (p *EthereumApi) GetBalance(args *GetBalanceArgs, reply *interface{}) error { - if err := args.requirements(); err != nil { - return err - } - *reply = common.ToHex(p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance().Bytes()) - return nil -} - func (p *EthereumApi) GetStorage(args *GetStorageArgs, reply *interface{}) error { if err := args.requirements(); err != nil { return err @@ -506,7 +498,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.GetBalance(args, reply) + + if err := args.requirements(); err != nil { + return err + } + + *reply = common.ToHex(p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance().Bytes()) case "eth_getStorage", "eth_storageAt": args := new(GetStorageArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 3aea64510671c8f411f2efb0fed09e371027f9e6 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:02:31 -0400 Subject: inline GetStorage --- rpc/api.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 5654ee3d3..d91618671 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -282,14 +282,6 @@ func (p *EthereumApi) Call(args *NewTxArgs, reply *interface{}) error { return nil } -func (p *EthereumApi) GetStorage(args *GetStorageArgs, reply *interface{}) error { - if err := args.requirements(); err != nil { - return err - } - *reply = p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Storage() - return nil -} - func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) error { if err := args.requirements(); err != nil { return err @@ -509,7 +501,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.GetStorage(args, reply) + + if err := args.requirements(); err != nil { + return err + } + + *reply = p.xethWithStateNum(args.BlockNumber).State().SafeGet(args.Address).Storage() case "eth_getStorageAt": args := new(GetStorageAtArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From e530c960a4b334815b3c9563b8b0b6809c082548 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:03:27 -0400 Subject: inline GetTxCountAt --- rpc/api.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index d91618671..820bb23b0 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,15 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) GetTxCountAt(args *GetTxCountArgs, reply *interface{}) error { - err := args.requirements() - if err != nil { - return err - } - *reply = p.xethWithStateNum(args.BlockNumber).TxCountAt(args.Address) - return nil -} - func (p *EthereumApi) GetData(args *GetDataArgs, reply *interface{}) error { if err := args.requirements(); err != nil { return err @@ -518,7 +509,13 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.GetTxCountAt(args, reply) + + err := args.requirements() + if err != nil { + return err + } + + *reply = p.xethWithStateNum(args.BlockNumber).TxCountAt(args.Address) case "eth_getBlockTransactionCountByHash": args := new(GetBlockByHashArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 152b37ee116db8faa4d6dbc254336ba1fa7e94ab Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:04:02 -0400 Subject: inline GetData --- rpc/api.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 820bb23b0..f8ba82276 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,14 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) GetData(args *GetDataArgs, reply *interface{}) error { - if err := args.requirements(); err != nil { - return err - } - *reply = p.xethWithStateNum(args.BlockNumber).CodeAt(args.Address) - return nil -} - func (p *EthereumApi) GetCompilers(reply *interface{}) error { c := []string{""} *reply = c @@ -565,7 +557,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.GetData(args, reply) + if err := args.requirements(); err != nil { + return err + } + *reply = p.xethWithStateNum(args.BlockNumber).CodeAt(args.Address) case "eth_sendTransaction", "eth_transact": args := new(NewTxArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From d28cd0f04086ce618f16b5019d2fd3992469755a Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:04:40 -0400 Subject: inline GetCompilers --- rpc/api.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index f8ba82276..432959bc2 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,12 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) GetCompilers(reply *interface{}) error { - c := []string{""} - *reply = c - return nil -} - func (p *EthereumApi) DbPut(args *DbArgs, reply *interface{}) error { if err := args.requirements(); err != nil { return err @@ -670,7 +664,8 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error } *reply = uncle case "eth_getCompilers": - return p.GetCompilers(reply) + c := []string{""} + *reply = c case "eth_compileSolidity", "eth_compileLLL", "eth_compileSerpent": return NewNotImplementedError(req.Method) case "eth_newFilter": -- cgit From 6fef6168705a9e70f36560b100d276092ecb5bff Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:05:48 -0400 Subject: inline DbPut --- rpc/api.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 432959bc2..62b8199f1 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,16 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) DbPut(args *DbArgs, reply *interface{}) error { - if err := args.requirements(); err != nil { - return err - } - - p.db.Put([]byte(args.Database+args.Key), []byte(args.Value)) - *reply = true - return nil -} - func (p *EthereumApi) DbGet(args *DbArgs, reply *interface{}) error { if err := args.requirements(); err != nil { return err @@ -711,7 +701,13 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.DbPut(args, reply) + + if err := args.requirements(); err != nil { + return err + } + + p.db.Put([]byte(args.Database+args.Key), []byte(args.Value)) + *reply = true case "db_getString": args := new(DbArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 57f6a3b5c06f1fcb6bfff5741a6f69f6cf55d89d Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:06:35 -0400 Subject: inline DbGet --- rpc/api.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 62b8199f1..e2a18528b 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,16 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) DbGet(args *DbArgs, reply *interface{}) error { - if err := args.requirements(); err != nil { - return err - } - - res, _ := p.db.Get([]byte(args.Database + args.Key)) - *reply = string(res) - return nil -} - func (p *EthereumApi) NewWhisperIdentity(reply *interface{}) error { *reply = p.xeth().Whisper().NewIdentity() return nil @@ -713,7 +703,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.DbGet(args, reply) + if err := args.requirements(); err != nil { + return err + } + + res, _ := p.db.Get([]byte(args.Database + args.Key)) + *reply = string(res) case "db_putHex", "db_getHex": return NewNotImplementedError(req.Method) case "shh_post": -- cgit From 85e03217de038fc84f5161c81468ed7f218bd876 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:09:54 -0400 Subject: inline NewWhisperIdentity --- rpc/api.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index e2a18528b..0d67afca0 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,11 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -func (p *EthereumApi) NewWhisperIdentity(reply *interface{}) error { - *reply = p.xeth().Whisper().NewIdentity() - return nil -} - // func (p *EthereumApi) RemoveWhisperIdentity(args *WhisperIdentityArgs, reply *interface{}) error { // *reply = p.xeth().Whisper().RemoveIdentity(args.Identity) // return nil @@ -703,6 +698,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } + if err := args.requirements(); err != nil { return err } @@ -718,7 +714,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error } return p.WhisperPost(args, reply) case "shh_newIdentity": - return p.NewWhisperIdentity(reply) + *reply = p.xeth().Whisper().NewIdentity() // case "shh_removeIdentity": // args := new(WhisperIdentityArgs) // if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 0eb9572d642ee7fe5d730b6396f5c348c482e7d6 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:10:05 -0400 Subject: inline RemoveWhisperIdentity --- rpc/api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 0d67afca0..7ecde4c24 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -303,11 +303,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e return nil } -// func (p *EthereumApi) RemoveWhisperIdentity(args *WhisperIdentityArgs, reply *interface{}) error { -// *reply = p.xeth().Whisper().RemoveIdentity(args.Identity) -// return nil -// } - func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface{}) error { var id int opts := new(xeth.Options) @@ -720,7 +715,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error // if err := json.Unmarshal(req.Params, &args); err != nil { // return err // } - // return p.RemoveWhisperIdentity(args, reply) + // *reply = p.xeth().Whisper().RemoveIdentity(args.Identity) case "shh_hasIdentity": args := new(WhisperIdentityArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From cc91ba0add5e21a6d2f67a16ee5f08b74b597edd Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:12:12 -0400 Subject: inline GetTransactionByHash --- rpc/api.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 7ecde4c24..ff89bbecf 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -352,14 +352,6 @@ func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error { return nil } -func (p *EthereumApi) GetTransactionByHash(hash string, reply *interface{}) error { - tx := p.xeth().EthTransactionByHash(hash) - if tx != nil { - *reply = NewTransactionRes(tx) - } - return nil -} - func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) { block := p.xeth().EthBlockByHash(blockhash) br := NewBlockRes(block) @@ -566,7 +558,10 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { } - return p.GetTransactionByHash(args.Hash, reply) + tx := p.xeth().EthTransactionByHash(hash) + if tx != nil { + *reply = NewTransactionRes(tx) + } case "eth_getTransactionByBlockHashAndIndex": args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From b28e6d830606346d42d46ab657d3ba2b5b1a994e Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:12:52 -0400 Subject: inline WhisperMessages --- rpc/api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index ff89bbecf..2b2467400 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -347,11 +347,6 @@ func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{}) return nil } -func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error { - *reply = p.xeth().Whisper().Messages(id) - return nil -} - func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) { block := p.xeth().EthBlockByHash(blockhash) br := NewBlockRes(block) @@ -742,7 +737,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.WhisperMessages(args.Id, reply) + *reply = p.xeth().Whisper().Messages(id) // case "eth_register": // args, err := req.ToRegisterArgs() // if err != nil { -- cgit From 22546dcb5528109de910e722cfc1afd5446eb3eb Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:14:27 -0400 Subject: inline UninstallWhisperFilter --- rpc/api.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 2b2467400..cd34934cf 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -320,12 +320,6 @@ func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface return nil } -func (p *EthereumApi) UninstallWhisperFilter(id int, reply *interface{}) error { - delete(p.messages, id) - *reply = true - return nil -} - func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error { self.messagesMut.Lock() defer self.messagesMut.Unlock() @@ -725,7 +719,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.UninstallWhisperFilter(args.Id, reply) + + if _, ok := p.messages[args.Id]; ok { + delete(p.messages, args.Id) + } + + *reply = true case "shh_getFilterChanges": args := new(FilterIdArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 7e6c8a411d73f1406ec12d6a75225a2a60fdfa45 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:26:09 -0400 Subject: fixes --- rpc/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index cd34934cf..fcab90f3b 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -547,7 +547,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error args := new(HashIndexArgs) if err := json.Unmarshal(req.Params, &args); err != nil { } - tx := p.xeth().EthTransactionByHash(hash) + tx := p.xeth().EthTransactionByHash(args.Hash) if tx != nil { *reply = NewTransactionRes(tx) } @@ -736,7 +736,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - *reply = p.xeth().Whisper().Messages(id) + *reply = p.xeth().Whisper().Messages(args.Id) // case "eth_register": // args, err := req.ToRegisterArgs() // if err != nil { -- cgit From 216175c265e7c5a82e47df3302f285104593dfa8 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:28:25 -0400 Subject: inline GetBlockUncleCountByNumber --- rpc/api.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index fcab90f3b..acec7f457 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -373,12 +373,6 @@ func (p *EthereumApi) GetBlockUncleCountByHash(blockhash string) (int64, error) return int64(len(br.Uncles)), nil } -func (p *EthereumApi) GetBlockUncleCountByNumber(blocknum int64) (int64, error) { - block := p.xeth().EthBlockByNumber(blocknum) - br := NewBlockRes(block) - return int64(len(br.Uncles)), nil -} - func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { // Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC rpclogger.Debugf("%s %s", req.Method, req.Params) @@ -492,11 +486,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } - v, err := p.GetBlockUncleCountByNumber(args.BlockNumber) - if err != nil { - return err - } - *reply = common.ToHex(big.NewInt(v).Bytes()) + block := p.xeth().EthBlockByNumber(args.BlockNumber) + br := NewBlockRes(block) + *reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes()) case "eth_getData", "eth_getCode": args := new(GetDataArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From c57eb286d66c01af0116e12a2476f546727e88ae Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:29:46 -0400 Subject: inline GetBlockUncleCountByHash --- rpc/api.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index acec7f457..b17b51317 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -367,12 +367,6 @@ func (p *EthereumApi) GetBlockTransactionCountByNumber(blocknum int64) (int64, e return int64(len(br.Transactions)), nil } -func (p *EthereumApi) GetBlockUncleCountByHash(blockhash string) (int64, error) { - block := p.xeth().EthBlockByHash(blockhash) - br := NewBlockRes(block) - return int64(len(br.Uncles)), nil -} - func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { // Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC rpclogger.Debugf("%s %s", req.Method, req.Params) @@ -475,11 +469,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } - v, err := p.GetBlockUncleCountByHash(args.BlockHash) - if err != nil { - return err - } - *reply = common.ToHex(big.NewInt(v).Bytes()) + block := p.xeth().EthBlockByHash(args.BlockHash) + br := NewBlockRes(block) + *reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes()) case "eth_getUncleCountByBlockNumber": args := new(GetBlockByNumberArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From ff657edbb6222db826175965f9ec5b26dbf4385e Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:30:42 -0400 Subject: inline GetBlockTransactionCountByNumber --- rpc/api.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index b17b51317..b9e2ca09d 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -361,12 +361,6 @@ func (p *EthereumApi) GetBlockTransactionCountByHash(blockhash string) (int64, e return int64(len(br.Transactions)), nil } -func (p *EthereumApi) GetBlockTransactionCountByNumber(blocknum int64) (int64, error) { - block := p.xeth().EthBlockByNumber(blocknum) - br := NewBlockRes(block) - return int64(len(br.Transactions)), nil -} - func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { // Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC rpclogger.Debugf("%s %s", req.Method, req.Params) @@ -458,11 +452,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } - v, err := p.GetBlockTransactionCountByNumber(args.BlockNumber) - if err != nil { - return err - } - *reply = common.ToHex(big.NewInt(v).Bytes()) + block := p.xeth().EthBlockByNumber(args.BlockNumber) + br := NewBlockRes(block) + *reply = common.ToHex(big.NewInt(int64(len(br.Transactions))).Bytes()) case "eth_getUncleCountByBlockHash": args := new(GetBlockByHashArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From 0895190b64204205ed9cbc52a65b1060db4e43b4 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:31:40 -0400 Subject: inline GetBlockTransactionCountByHash --- rpc/api.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index b9e2ca09d..ded8b0296 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -355,12 +355,6 @@ func (p *EthereumApi) GetBlockByNumber(blocknum int64, includetx bool) (*BlockRe return br, nil } -func (p *EthereumApi) GetBlockTransactionCountByHash(blockhash string) (int64, error) { - block := p.xeth().EthBlockByHash(blockhash) - br := NewBlockRes(block) - return int64(len(br.Transactions)), nil -} - func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { // Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC rpclogger.Debugf("%s %s", req.Method, req.Params) @@ -441,11 +435,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } - v, err := p.GetBlockTransactionCountByHash(args.BlockHash) - if err != nil { - return err - } - *reply = common.ToHex(big.NewInt(v).Bytes()) + block := p.xeth().EthBlockByHash(args.BlockHash) + br := NewBlockRes(block) + *reply = common.ToHex(big.NewInt(int64(len(br.Transactions))).Bytes()) case "eth_getBlockTransactionCountByNumber": args := new(GetBlockByNumberArgs) if err := json.Unmarshal(req.Params, &args); err != nil { -- cgit From cdfc03dc8e11a1738cad8009095549ea2d4b8287 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 19 Mar 2015 20:40:50 -0400 Subject: inline WhisperPost --- rpc/api.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index ded8b0296..961440493 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -331,16 +331,6 @@ func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error { return nil } -func (p *EthereumApi) WhisperPost(args *WhisperMessageArgs, reply *interface{}) error { - err := p.xeth().Whisper().Post(args.Payload, args.To, args.From, args.Topics, args.Priority, args.Ttl) - if err != nil { - return err - } - - *reply = true - return nil -} - func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) { block := p.xeth().EthBlockByHash(blockhash) br := NewBlockRes(block) @@ -659,7 +649,13 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error if err := json.Unmarshal(req.Params, &args); err != nil { return err } - return p.WhisperPost(args, reply) + + err := p.xeth().Whisper().Post(args.Payload, args.To, args.From, args.Topics, args.Priority, args.Ttl) + if err != nil { + return err + } + + *reply = true case "shh_newIdentity": *reply = p.xeth().Whisper().NewIdentity() // case "shh_removeIdentity": -- cgit