func (bs *boltStorage) InitialState() (raftpb.HardState, raftpb.ConfState, error) {
	tx, err := bs.db.Begin(false)
	if err != nil {
		return raftpb.HardState{}, raftpb.ConfState{}, raft.ErrUnavailable
	}

	defer tx.Rollback()
	st, stErr := bs.loadHardState(tx)
	if stErr != nil {
		bs.logger.Errorf("Can't load hard state: %s", stErr.Error())
	}

	cSt, cStErr := bs.loadConfState(tx)
	if cStErr != nil {
		bs.logger.Errorf("Can't load hard state: %s", cStErr.Error())
	}

	var stToReturn raftpb.HardState
	var cStToReturn raftpb.ConfState
	var errToReturn error

	if stErr == nil && st != nil {
		stToReturn = *st
		errToReturn = nil
	} else {
		stToReturn = raftpb.HardState{}
		errToReturn = stErr
	}

	if cStErr == nil && cSt != nil {
		cStToReturn = *cSt
	} else {
		cStToReturn = raftpb.ConfState{}
		errToReturn = cStErr
	}

	bs.logger.Infof("Starting node with: %s %s", stToReturn.String(), cStToReturn.String())
	return stToReturn, cStToReturn, errToReturn
}
// InitialState returns the saved HardState and ConfState information.
InitialState returns the saved HardState and ConfState information.
// InitialState returns the saved HardState and ConfState information .
func (bs *boltStorage) InitialState() (raftpb.HardState, raftpb.ConfState, error) {
	tx, err := bs.db.Begin(false)
	if err != nil {
		return raftpb.HardState{}, raftpb.ConfState{}, raft.ErrUnavailable
	}
	defer tx.Rollback()
	st, stErr := bs.loadHardState(tx)
	if stErr != nil {
		bs.logger.Errorf("Can't load hard state: %s", stErr.Error())
	}
	cSt, cStErr := bs.loadConfState(tx)
	if cStErr != nil {
		bs.logger.Errorf("Can't load hard state: %s", cStErr.Error())
	}
	var stToReturn raftpb.HardState
	var cStToReturn raftpb.ConfState
	var errToReturn error
	if stErr == nil && st != nil {
		stToReturn = *st
		errToReturn = nil
	} else {
		stToReturn = raftpb.HardState{}
		errToReturn = stErr
	}
	if cStErr == nil && cSt != nil {
		cStToReturn = *cSt
	} else {
		cStToReturn = raftpb.ConfState{}
		errToReturn = cStErr
	}
	bs.logger.Infof("Starting node with: %s %s", stToReturn.String(), cStToReturn.String())
	return stToReturn, cStToReturn, errToReturn
}
func ( bs * boltStorage ) InitialState ( ) ( raftpb . HardState , raftpb . ConfState , error ) { tx , err := bs . db . Begin ( false ) if err != nil { return raftpb . HardState { } , raftpb . ConfState { } , raft . ErrUnavailable } defer tx . Rollback ( ) st , stErr := bs . loadHardState ( tx ) if stErr != nil { bs . logger . Errorf ( " " , stErr . Error ( ) ) } cSt , cStErr := bs . loadConfState ( tx ) if cStErr != nil { bs . logger . Errorf ( " " , cStErr . Error ( ) ) } var stToReturn raftpb . HardState var cStToReturn raftpb . ConfState var errToReturn error if stErr == nil && st != nil { stToReturn = * st errToReturn = nil } else { stToReturn = raftpb . HardState { } errToReturn = stErr } if cStErr == nil && cSt != nil { cStToReturn = * cSt } else { cStToReturn = raftpb . ConfState { } errToReturn = cStErr } bs . logger . Infof ( " " , stToReturn . String ( ) , cStToReturn . String ( ) ) return stToReturn , cStToReturn , errToReturn }
InitialState returns the saved HardState and ConfState information.
InitialState returns the saved HardState and ConfState information .