Exemple #1
0
func (n *Node_t) Register(h *types.Host_t, reply *types.Host_t) error {
	nodemap := *n.Nodemap
	fmt.Print("Register request: '" + h.String() + "'\t... ")
	if nodemap == nil {
		panic(nil)
	}

	_, ok := nodemap[h.ID]
	if ok {
		fmt.Println("Got register request from someone I already know")
		return errors.New("P O")
	}

	n.getJoinHost(h, reply)
	n.addNode(h)
	fmt.Print("Telling new host to join on\t'" + reply.String() + "' ... ")
	fmt.Println("OK")

	return nil
}