forked from cerc-io/plugeth
Update signature for rpc websockets
This commit is contained in:
parent
7139c1aff7
commit
b2b42f759c
@ -205,7 +205,7 @@ func StartWebSockets(eth *eth.Ethereum, wsPort int) {
|
|||||||
clilogger.Infoln("Starting WebSockets")
|
clilogger.Infoln("Starting WebSockets")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
eth.WsServer, err = rpcws.NewWebSocketServer(eth, wsPort)
|
eth.WsServer, err = rpcws.NewWebSocketServer(xeth.New(eth), wsPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
clilogger.Errorf("Could not start RPC interface (port %v): %v", wsPort, err)
|
clilogger.Errorf("Could not start RPC interface (port %v): %v", wsPort, err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,8 +22,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.google.com/p/go.net/websocket"
|
"code.google.com/p/go.net/websocket"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
|
||||||
"github.com/ethereum/go-ethereum/event/filter"
|
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
@ -32,25 +30,21 @@ import (
|
|||||||
var wslogger = logger.NewLogger("RPC-WS")
|
var wslogger = logger.NewLogger("RPC-WS")
|
||||||
|
|
||||||
type WebSocketServer struct {
|
type WebSocketServer struct {
|
||||||
eth *eth.Ethereum
|
pipe *xeth.XEth
|
||||||
filterManager *filter.FilterManager
|
port int
|
||||||
port int
|
doneCh chan bool
|
||||||
doneCh chan bool
|
listener net.Listener
|
||||||
listener net.Listener
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWebSocketServer(eth *eth.Ethereum, port int) (*WebSocketServer, error) {
|
func NewWebSocketServer(pipe *xeth.XEth, port int) (*WebSocketServer, error) {
|
||||||
sport := fmt.Sprintf(":%d", port)
|
sport := fmt.Sprintf(":%d", port)
|
||||||
l, err := net.Listen("tcp", sport)
|
l, err := net.Listen("tcp", sport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
filterManager := filter.NewFilterManager(eth.EventMux())
|
return &WebSocketServer{
|
||||||
go filterManager.Start()
|
pipe,
|
||||||
|
|
||||||
return &WebSocketServer{eth,
|
|
||||||
filterManager,
|
|
||||||
port,
|
port,
|
||||||
make(chan bool),
|
make(chan bool),
|
||||||
l,
|
l,
|
||||||
@ -75,7 +69,7 @@ func (self *WebSocketServer) Start() {
|
|||||||
wslogger.Infof("Starting RPC-WS server on port %d", self.port)
|
wslogger.Infof("Starting RPC-WS server on port %d", self.port)
|
||||||
go self.handlerLoop()
|
go self.handlerLoop()
|
||||||
|
|
||||||
api := rpc.NewEthereumApi(xeth.New(self.eth))
|
api := rpc.NewEthereumApi(self.pipe)
|
||||||
h := self.apiHandler(api)
|
h := self.apiHandler(api)
|
||||||
http.Handle("/ws", h)
|
http.Handle("/ws", h)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user