Skip to content

Instantly share code, notes, and snippets.

@beber89
beber89 / node.go
Created September 24, 2019 10:48
mine-dapp-wasm/chainfabric/node/struct
// Node represents a user in the network
// toIP is IP address of server to connect to
// toPort is Port address of server to connect to
// response is value unassignable by user, only read
type Node struct {
toIP string
toPort uint16
response string
ws js.Value
newTransactionCallback func(string)
@beber89
beber89 / node.go
Created September 24, 2019 10:56
mine-dapp-wasm/chainfabric/node/Connect
// Connect connects node to remote server via TCP
func (nd *Node) Connect() bool {
// connect to this socket
nd.ws = js.Global().Get("WebSocket").New(fmt.Sprintf("ws://%s:%d/ws", nd.toIP, nd.toPort))
nd.ws.Call("addEventListener", "open", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
return nil
}))
nd.ws.Call("addEventListener", "message", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
message := args[0].Get("data").String()
Verifying my Blockstack ID is secured with the address 1DkrieQuUHrV4WZdNYqi1nCk7NVgwhh5V6 https://explorer.blockstack.org/address/1DkrieQuUHrV4WZdNYqi1nCk7NVgwhh5V6