|
|
@ -14,11 +14,7 @@ |
|
|
|
You should have received a copy of the GNU General Public License |
|
|
|
You should have received a copy of the GNU General Public License |
|
|
|
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/** |
|
|
|
package websocket |
|
|
|
* @authors |
|
|
|
|
|
|
|
* Jeffrey Wilcke <i@jev.io> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
package utils |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"github.com/ethereum/go-ethereum/core" |
|
|
|
"github.com/ethereum/go-ethereum/core" |
|
|
@ -26,15 +22,11 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/eth" |
|
|
|
"github.com/ethereum/go-ethereum/eth" |
|
|
|
"github.com/ethereum/go-ethereum/ethutil" |
|
|
|
"github.com/ethereum/go-ethereum/ethutil" |
|
|
|
"github.com/ethereum/go-ethereum/event/filter" |
|
|
|
"github.com/ethereum/go-ethereum/event/filter" |
|
|
|
"github.com/ethereum/go-ethereum/logger" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/state" |
|
|
|
"github.com/ethereum/go-ethereum/state" |
|
|
|
"github.com/ethereum/go-ethereum/ui" |
|
|
|
"github.com/ethereum/go-ethereum/ui" |
|
|
|
"github.com/ethereum/go-ethereum/websocket" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/xeth" |
|
|
|
"github.com/ethereum/go-ethereum/xeth" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var wslogger = logger.NewLogger("WS") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func args(v ...interface{}) []interface{} { |
|
|
|
func args(v ...interface{}) []interface{} { |
|
|
|
return v |
|
|
|
return v |
|
|
|
} |
|
|
|
} |
|
|
@ -54,8 +46,8 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer { |
|
|
|
func (self *WebSocketServer) Serv() { |
|
|
|
func (self *WebSocketServer) Serv() { |
|
|
|
pipe := xeth.NewJSXEth(self.eth) |
|
|
|
pipe := xeth.NewJSXEth(self.eth) |
|
|
|
|
|
|
|
|
|
|
|
wsServ := websocket.NewServer("/eth", ":40404") |
|
|
|
wsServ := NewServer("/eth", ":40404") |
|
|
|
wsServ.MessageFunc(func(c *websocket.Client, msg *websocket.Message) { |
|
|
|
wsServ.MessageFunc(func(c *Client, msg *Message) { |
|
|
|
switch msg.Call { |
|
|
|
switch msg.Call { |
|
|
|
case "compile": |
|
|
|
case "compile": |
|
|
|
data := ethutil.NewValue(msg.Args) |
|
|
|
data := ethutil.NewValue(msg.Args) |
|
|
@ -162,13 +154,6 @@ func toMessages(messages state.Messages) (msgs []xeth.JSMessage) { |
|
|
|
return |
|
|
|
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
|
|
|
|
// TODO This is starting to become a generic method. Move to utils
|
|
|
|
func mapToTxParams(object map[string]interface{}) map[string]string { |
|
|
|
func mapToTxParams(object map[string]interface{}) map[string]string { |
|
|
|
// Default values
|
|
|
|
// Default values
|