func NewMessagingNode(n *xn.Node, stopCh, stoppedCh chan bool) ( mn *MessagingNode, err error) { var k int if n == nil { err = NilNode } if err == nil { if k = n.SizePeers(); k == 0 { err = NoPeers } } tcpAcc := n.GetAcceptor(0).(*xt.TcpAcceptor) if err == nil && tcpAcc == nil { err = AcceptorNotLive } if err == nil && stopCh == nil { err = NilControlCh } if err == nil { mn = &MessagingNode{ Acc: tcpAcc, K: k, StopCh: stopCh, StoppedCh: stoppedCh, Node: *n, } } return }
/** * Returns AcceptorNotLive if the node does not have an open acceptor. */ func NewRegNode(node *xn.Node, commsKey, sigKey *rsa.PrivateKey) ( q *RegNode, err error) { var acc xt.AcceptorI if node == nil { err = NilNode // We would prefer that the node's name be xlReg and that its // LFS default to /var/app/xlReg. } else { acc = node.GetAcceptor(0) if acc == nil { err = xm.AcceptorNotLive } if err == nil { stopCh := make(chan bool, 1) stoppedCh := make(chan bool, 1) q = &RegNode{ Acc: acc, StopCh: stopCh, StoppedCh: stoppedCh, ckPriv: commsKey, skPriv: sigKey, Node: *node, } } } return }