func (bs *badgerStorage) loadConfState(txn *badger.Txn) (*raftpb.ConfState, error) {
	cs := &raftpb.ConfState{}
	var item *badger.Item
	var txnErr error
	var bites []byte
	item, txnErr = txn.Get(confStateKey)
	if txnErr == badger.ErrKeyNotFound {
		return cs, nil
	} else if txnErr != nil {
		return cs, txnErr
	}

	bites, txnErr = item.Value()
	if txnErr != nil {
		return cs, txnErr
	}

	txnErr = cs.Unmarshal(bites)
	if txnErr != nil {
		return cs, txnErr
	}

	return cs, nil
}
// NB: can't return nil and must handle "key not found" errors
can't return nil and must handle "key not found" errors
// NB : can ' t return nil and must handle " key not found " errors
func (bs *badgerStorage) loadConfState(txn *badger.Txn) (*raftpb.ConfState, error) {
	cs := &raftpb.ConfState{}
	var item *badger.Item
	var txnErr error
	var bites []byte
	item, txnErr = txn.Get(confStateKey)
	if txnErr == badger.ErrKeyNotFound {
		return cs, nil
	} else if txnErr != nil {
		return cs, txnErr
	}
	bites, txnErr = item.Value()
	if txnErr != nil {
		return cs, txnErr
	}
	txnErr = cs.Unmarshal(bites)
	if txnErr != nil {
		return cs, txnErr
	}
	return cs, nil
}
func ( bs * badgerStorage ) loadConfState ( txn * badger . Txn ) ( * raftpb . ConfState , error ) { cs := & raftpb . ConfState { } var item * badger . Item var txnErr error var bites [ ] byte item , txnErr = txn . Get ( confStateKey ) if txnErr == badger . ErrKeyNotFound { return cs , nil } else if txnErr != nil { return cs , txnErr } bites , txnErr = item . Value ( ) if txnErr != nil { return cs , txnErr } txnErr = cs . Unmarshal ( bites ) if txnErr != nil { return cs , txnErr } return cs , nil }
can't return nil and must handle "key not found" errors
can ' t return nil and must handle " key not found " errors