Rename api var for clarity

poc8
Taylor Gerring 10 years ago
parent d8c6168d11
commit e9d017ba08
  1. 4
      rpc/http/server.go
  2. 9
      rpc/ws/server.go

@ -83,7 +83,7 @@ func (s *RpcHttpServer) Start() {
} }
} }
func (s *RpcHttpServer) apiHandler(xeth *rpc.EthereumApi) http.Handler { func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) { fn := func(w http.ResponseWriter, req *http.Request) {
rpchttplogger.Debugln("Handling request") rpchttplogger.Debugln("Handling request")
@ -94,7 +94,7 @@ func (s *RpcHttpServer) apiHandler(xeth *rpc.EthereumApi) http.Handler {
} }
var response interface{} var response interface{}
reserr := xeth.GetRequestReply(&reqParsed, &response) reserr := api.GetRequestReply(&reqParsed, &response)
if reserr != nil { if reserr != nil {
rpchttplogger.Errorln(reserr) rpchttplogger.Errorln(reserr)
JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()}) JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})

@ -85,9 +85,9 @@ func (self *WebSocketServer) Start() {
} }
} }
func (s *WebSocketServer) apiHandler(xeth *rpc.EthereumApi) http.Handler { func (s *WebSocketServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) { fn := func(w http.ResponseWriter, req *http.Request) {
h := sockHandler(xeth) h := sockHandler(api)
s := websocket.Server{Handler: h} s := websocket.Server{Handler: h}
s.ServeHTTP(w, req) s.ServeHTTP(w, req)
} }
@ -95,10 +95,9 @@ func (s *WebSocketServer) apiHandler(xeth *rpc.EthereumApi) http.Handler {
return http.HandlerFunc(fn) return http.HandlerFunc(fn)
} }
func sockHandler(xeth *rpc.EthereumApi) websocket.Handler { func sockHandler(api *rpc.EthereumApi) websocket.Handler {
fn := func(conn *websocket.Conn) { fn := func(conn *websocket.Conn) {
for { for {
// FIX wslogger does not output to console
wslogger.Debugln("Handling request") wslogger.Debugln("Handling request")
var reqParsed rpc.RpcRequest var reqParsed rpc.RpcRequest
@ -109,7 +108,7 @@ func sockHandler(xeth *rpc.EthereumApi) websocket.Handler {
} }
var response interface{} var response interface{}
reserr := xeth.GetRequestReply(&reqParsed, &response) reserr := api.GetRequestReply(&reqParsed, &response)
if reserr != nil { if reserr != nil {
wslogger.Errorln(reserr) wslogger.Errorln(reserr)
websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()}) websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})

Loading…
Cancel
Save