code: func New(c *Config) (*Node, error) {
  	if err := os.MkdirAll(c.StateDir, 0700); err != nil {
  		return nil, err
  	}
  	stateFile := filepath.Join(c.StateDir, stateFilename)
  	dt, err := ioutil.ReadFile(stateFile)
  	var p []api.Peer
  	if err != nil && !os.IsNotExist(err) {
  		return nil, err
  	}
  	if err == nil {
  		if err := json.Unmarshal(dt, &p); err != nil {
  			return nil, err
  		}
  	}
  	n := &Node{
  		remotes:          newPersistentRemotes(stateFile, p...),
  		role:             ca.WorkerRole,
  		config:           c,
  		started:          make(chan struct{}),
  		stopped:          make(chan struct{}),
  		closed:           make(chan struct{}),
  		ready:            make(chan struct{}),
  		notifyNodeChange: make(chan *agent.NodeChanges, 1),
  		unlockKey:        c.UnlockKey,
  	}
  
  	if n.config.JoinAddr != "" || n.config.ForceNewCluster {
  		n.remotes = newPersistentRemotes(filepath.Join(n.config.StateDir, stateFilename))
  		if n.config.JoinAddr != "" {
  			n.remotes.Observe(api.Peer{Addr: n.config.JoinAddr}, remotes.DefaultObservationWeight)
  		}
  	}
  
  	n.connBroker = connectionbroker.New(n.remotes)
  
  	n.roleCond = sync.NewCond(n.RLocker())
  	n.connCond = sync.NewCond(n.RLocker())
  	return n, nil
  }
docs: // New returns new Node instance.