aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-01-13 13:44:56 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-01-13 13:44:56 +0800
commitb2112729faa2263fe0dbf6f735339e27608ae614 (patch)
tree099020852839f85b257677b6c2ac447ba0b55dd4
parent32bed50ba107ff69ff489e4df6f935fd404a5caa (diff)
downloaddexon-b2112729faa2263fe0dbf6f735339e27608ae614.tar.gz
dexon-b2112729faa2263fe0dbf6f735339e27608ae614.tar.zst
dexon-b2112729faa2263fe0dbf6f735339e27608ae614.zip
cleanup
-rw-r--r--rpc/message.go21
-rw-r--r--rpc/packages.go34
2 files changed, 9 insertions, 46 deletions
diff --git a/rpc/message.go b/rpc/message.go
index f520548c9..8aadfa691 100644
--- a/rpc/message.go
+++ b/rpc/message.go
@@ -4,8 +4,6 @@ import (
"bytes"
"encoding/json"
"errors"
-
- // "github.com/ethereum/go-ethereum/ethutil"
)
const (
@@ -16,30 +14,11 @@ const (
ErrorDecodeArgs = "Error: Could not decode arguments"
)
-// type JsonResponse interface {
-// }
-
type ErrorResponse struct {
Error bool `json:"error"`
ErrorText string `json:"errorText"`
}
-// type SuccessRes struct {
-// Error bool `json:"error"`
-// Result JsonResponse `json:"result"`
-// }
-
-// type Message struct {
-// Call string `json:"call"`
-// Args []interface{} `json:"args"`
-// Id int `json:"_id"`
-// Data interface{} `json:"data"`
-// }
-
-// func (self *Message) Arguments() *ethutil.Value {
-// return ethutil.NewValue(self.Args)
-// }
-
type RpcSuccessResponse struct {
ID int `json:"id"`
JsonRpc string `json:"jsonrpc"`
diff --git a/rpc/packages.go b/rpc/packages.go
index 06f00678c..4414abf19 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -1,12 +1,19 @@
+/*
+
+For each request type, define the following:
+
+1. RpcRequest "To" method [message.go], which does basic validation and conversion to "Args" type via json.Decoder()
+2. json.Decoder() calls "UnmarshalJSON" defined on each "Args" struct
+3. EthereumApi "Get" method, taking the "Args" type and replying with an interface to be marshalled to JSON
+
+*/
package rpc
import (
- // "bytes"
"encoding/json"
"math/big"
"strings"
- // "errors"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/xeth"
)
@@ -21,12 +28,9 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
return err
}
- // var block xeth.JSBlock
if args.BlockNumber > 0 {
- // block := p.pipe.BlockByNumber(int32(args.BlockNumber))
*reply = p.pipe.BlockByNumber(args.BlockNumber)
} else {
- // block := p.pipe.BlockByHash(args.Hash)
*reply = p.pipe.BlockByHash(args.Hash)
}
return nil
@@ -97,13 +101,11 @@ func (p *EthereumApi) GetPeerCount(reply *interface{}) error {
func (p *EthereumApi) GetIsListening(reply *interface{}) error {
*reply = p.pipe.IsListening()
- // *reply = NewSuccessRes(GetListeningRes{IsListening: p.pipe.IsListening()})
return nil
}
func (p *EthereumApi) GetCoinbase(reply *interface{}) error {
*reply = p.pipe.CoinBase()
- // *reply = p.pipe.CoinBase()
return nil
}
@@ -131,14 +133,6 @@ func (p *EthereumApi) GetBalanceAt(args *GetBalanceArgs, reply *interface{}) err
return nil
}
-// type JsonArgs interface {
-// requirements() error
-// }
-
-// type BlockResponse struct {
-// JsonResponse
-// }
-
type GetBlockArgs struct {
BlockNumber int32
Hash string
@@ -306,13 +300,3 @@ type BalanceRes struct {
Balance string `json:"balance"`
Address string `json:"address"`
}
-
-// type TestRes struct {
-// JsonResponse `json:"-"`
-// Answer int `json:"answer"`
-// }
-
-// func (p *EthereumApi) Test(args *GetBlockArgs, reply *interface{}) error {
-// *reply = NewSuccessRes(TestRes{Answer: 15})
-// return nil
-// }