lxd/cluster/raft.go
func raftMaybeBootstrap(
	conf *raft.Config,
	logs *raftboltdb.BoltStore,
	snaps raft.SnapshotStore,
	trans raft.Transport) error {
	// First check if we were already bootstrapped.
	hasExistingState, err := raft.HasExistingState(logs, logs, snaps)
	if err != nil {
		return errors.Wrap(err, "failed to check if raft has existing state")
	}
	if hasExistingState {
		return nil
	}
	server := raft.Server{
		ID:      conf.LocalID,
		Address: trans.LocalAddr(),
	}
	configuration := raft.Configuration{
		Servers: []raft.Server{server},
	}
	return raft.BootstrapCluster(conf, logs, logs, snaps, trans, configuration)
}
func raftMaybeBootstrap(
	conf *raft.Config,
	logs *raftboltdb.BoltStore,
	snaps raft.SnapshotStore,
	trans raft.Transport) error {
	// First check if we were already bootstrapped.
	hasExistingState, err := raft.HasExistingState(logs, logs, snaps)
	if err != nil {
		return errors.Wrap(err, "failed to check if raft has existing state")
	}
	if hasExistingState {
		return nil
	}
	server := raft.Server{
		ID:      conf.LocalID,
		Address: trans.LocalAddr(),
	}
	configuration := raft.Configuration{
		Servers: []raft.Server{server},
	}
	return raft.BootstrapCluster(conf, logs, logs, snaps, trans, configuration)
}
func raftMaybeBootstrap ( conf * raft . Config , logs * raftboltdb . BoltStore , snaps raft . SnapshotStore , trans raft . Transport ) error { // First check if we were already bootstrapped. hasExistingState , err := raft . HasExistingState ( logs , logs , snaps ) if err != nil { return errors . Wrap ( err , " " ) } if hasExistingState { return nil } server := raft . Server { ID : conf . LocalID , Address : trans . LocalAddr ( ) , } configuration := raft . Configuration { Servers : [ ] raft . Server { server } , } return raft . BootstrapCluster ( conf , logs , logs , snaps , trans , configuration ) }
// Helper to bootstrap the raft cluster if needed.
Helper to bootstrap the raft cluster if needed .