The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/waitnode/waitNode.go

50 lines
1.1 KiB

package waitnode
import (
6 years ago
"fmt"
"net"
"os"
"github.com/simple-rules/harmony-benchmark/log"
"github.com/simple-rules/harmony-benchmark/p2p"
)
//WaitNode is for nodes waiting to join consensus
type WaitNode struct {
Peer p2p.Peer
6 years ago
Log log.Logger
}
// StartServer a server and process the request by a handler.
func (node *WaitNode) StartServer(add p2p.Peer) {
6 years ago
node.Log.Debug("Starting waitnode on server %d", "node", node.Peer.Ip, "port", node.Peer.Port)
6 years ago
node.connectIdentityChain(add.Port)
}
6 years ago
func (node *WaitNode) connectIdentityChain(port string) {
// replace by p2p peer
6 years ago
identityChainIP := "127.0.0.1"
6 years ago
fmt.Println("Connecting to identity chain")
6 years ago
conn, err := net.Dial("tcp4", identityChainIP+":"+port)
defer conn.Close()
if err != nil {
6 years ago
node.Log.Crit("Socket listen port failed", "port", port, "err", err)
os.Exit(1)
}
//for {
6 years ago
// conn, err := listen.Accept()
// if err != nil {
// node.log.Crit("Error listening on port. Exiting.", "port", port)
// continue
// }
// }
}
// New Create a new Node
6 years ago
func New(Peer p2p.Peer) *WaitNode {
node := WaitNode{}
6 years ago
node.Peer = Peer
node.Log = log.New()
return &node
}