forked from cerc-io/plugeth
Move websockets out of cmd/util
This commit is contained in:
parent
d92fde6980
commit
0c77a96249
@ -40,6 +40,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/websocket"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
)
|
||||
|
||||
@ -200,6 +201,13 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
|
||||
}
|
||||
}
|
||||
|
||||
func StartWebSockets(eth *eth.Ethereum) {
|
||||
clilogger.Infoln("Starting WebSockets")
|
||||
|
||||
sock := websocket.NewWebSocketServer(eth)
|
||||
go sock.Serv()
|
||||
}
|
||||
|
||||
var gminer *miner.Miner
|
||||
|
||||
func GetMiner() *miner.Miner {
|
||||
|
@ -14,11 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @authors
|
||||
* Jeffrey Wilcke <i@jev.io>
|
||||
*/
|
||||
package utils
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@ -26,15 +22,11 @@ import (
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/event/filter"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/ui"
|
||||
"github.com/ethereum/go-ethereum/websocket"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
)
|
||||
|
||||
var wslogger = logger.NewLogger("WS")
|
||||
|
||||
func args(v ...interface{}) []interface{} {
|
||||
return v
|
||||
}
|
||||
@ -54,8 +46,8 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer {
|
||||
func (self *WebSocketServer) Serv() {
|
||||
pipe := xeth.NewJSXEth(self.eth)
|
||||
|
||||
wsServ := websocket.NewServer("/eth", ":40404")
|
||||
wsServ.MessageFunc(func(c *websocket.Client, msg *websocket.Message) {
|
||||
wsServ := NewServer("/eth", ":40404")
|
||||
wsServ.MessageFunc(func(c *Client, msg *Message) {
|
||||
switch msg.Call {
|
||||
case "compile":
|
||||
data := ethutil.NewValue(msg.Args)
|
||||
@ -162,13 +154,6 @@ func toMessages(messages state.Messages) (msgs []xeth.JSMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
func StartWebSockets(eth *eth.Ethereum) {
|
||||
wslogger.Infoln("Starting WebSockets")
|
||||
|
||||
sock := NewWebSocketServer(eth)
|
||||
go sock.Serv()
|
||||
}
|
||||
|
||||
// TODO This is starting to become a generic method. Move to utils
|
||||
func mapToTxParams(object map[string]interface{}) map[string]string {
|
||||
// Default values
|
Loading…
Reference in New Issue
Block a user