aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/api.go58
-rw-r--r--xeth/xeth.go36
2 files changed, 48 insertions, 46 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 4758363d1..87cf42ff5 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -16,12 +16,7 @@ import (
type EthereumApi struct {
eth *xeth.XEth
xethMu sync.RWMutex
-
- // // Register keeps a list of accounts and transaction data
- // regmut sync.Mutex
- // register map[string][]*NewTxArgs
-
- db common.Database
+ db common.Database
}
func NewEthereumApi(eth *xeth.XEth, dataDir string) *EthereumApi {
@@ -42,39 +37,9 @@ func (self *EthereumApi) xeth() *xeth.XEth {
return self.eth
}
-// func (self *EthereumApi) Register(args string, reply *interface{}) error {
-// self.regmut.Lock()
-// defer self.regmut.Unlock()
-
-// if _, ok := self.register[args]; ok {
-// self.register[args] = nil // register with empty
-// }
-// return nil
-// }
-
-// func (self *EthereumApi) Unregister(args string, reply *interface{}) error {
-// self.regmut.Lock()
-// defer self.regmut.Unlock()
-
-// delete(self.register, args)
-
-// return nil
-// }
-
-// func (self *EthereumApi) WatchTx(args string, reply *interface{}) error {
-// self.regmut.Lock()
-// defer self.regmut.Unlock()
-
-// txs := self.register[args]
-// self.register[args] = nil
-
-// *reply = txs
-// return nil
-// }
-
func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
- rpclogger.Infof("%s %s", req.Method, req.Params)
+ rpclogger.DebugDetailf("%s %s", req.Method, req.Params)
switch req.Method {
case "web3_sha3":
args := new(Sha3Args)
@@ -458,23 +423,24 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
*reply = p.xeth().Whisper().Messages(args.Id)
// case "eth_register":
- // args, err := req.ToRegisterArgs()
- // if err != nil {
+ // // Placeholder for actual type
+ // args := new(HashIndexArgs)
+ // if err := json.Unmarshal(req.Params, &args); err != nil {
// return err
// }
- // return p.Register(args, reply)
+ // *reply = p.xeth().Register(args.Hash)
// case "eth_unregister":
- // args, err := req.ToRegisterArgs()
- // if err != nil {
+ // args := new(HashIndexArgs)
+ // if err := json.Unmarshal(req.Params, &args); err != nil {
// return err
// }
- // return p.Unregister(args, reply)
+ // *reply = p.xeth().Unregister(args.Hash)
// case "eth_watchTx":
- // args, err := req.ToWatchTxArgs()
- // if err != nil {
+ // args := new(HashIndexArgs)
+ // if err := json.Unmarshal(req.Params, &args); err != nil {
// return err
// }
- // return p.WatchTx(args, reply)
+ // *reply = p.xeth().PullWatchTx(args.Hash)
default:
return NewNotImplementedError(req.Method)
}
diff --git a/xeth/xeth.go b/xeth/xeth.go
index e1e25ba09..636ee32c9 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -95,6 +95,9 @@ type XEth struct {
messagesMut sync.RWMutex
messages map[int]*whisperFilter
+
+ // regmut sync.Mutex
+ // register map[string][]*interface{} // TODO improve return type
}
// New creates an XEth that uses the given frontend.
@@ -434,6 +437,39 @@ func (self *XEth) MessagesChanged(id int) []WhisperMessage {
return nil
}
+// func (self *XEth) Register(args string) bool {
+// self.regmut.Lock()
+// defer self.regmut.Unlock()
+
+// if _, ok := self.register[args]; ok {
+// self.register[args] = nil // register with empty
+// }
+// return true
+// }
+
+// func (self *XEth) Unregister(args string) bool {
+// self.regmut.Lock()
+// defer self.regmut.Unlock()
+
+// if _, ok := self.register[args]; ok {
+// delete(self.register, args)
+// return true
+// }
+
+// return false
+// }
+
+// // TODO improve return type
+// func (self *XEth) PullWatchTx(args string) []*interface{} {
+// self.regmut.Lock()
+// defer self.regmut.Unlock()
+
+// txs := self.register[args]
+// self.register[args] = nil
+
+// return txs
+// }
+
type KeyVal struct {
Key string `json:"key"`
Value string `json:"value"`