func (bs *boltStorage) Term(i uint64) (uint64, error) {
	tx, err := bs.db.Begin(false)
	if err != nil {
		return 0, err
	}

	defer tx.Rollback()
	bites := tx.Bucket(entriesBucket).Get(uint64ToBytes(i))
	if bites == nil || len(bites) == 0 {
		// return 0, raft.ErrUnavailable
		return 0, nil
	}

	entry := &raftpb.Entry{}
	err = proto.Unmarshal(bites, entry)
	if err != nil {
		return 0, err
	}

	return entry.Term, nil
}
// Term returns the term of entry i, which must be in the range
// [FirstIndex()-1, LastIndex()]. The term of the entry before
// FirstIndex is retained for matching purposes even though the
// rest of that entry may not be available.
Term returns the term of entry i, which must be in the range
[FirstIndex()-1, LastIndex()]. The term of the entry before
FirstIndex is retained for matching purposes even though the
rest of that entry may not be available.
// Term returns the term of entry i which must be in the range // [ FirstIndex () - 1 LastIndex () ] . The term of the entry before // FirstIndex is retained for matching purposes even though the // rest of that entry may not be available .
func (bs *boltStorage) Term(i uint64) (uint64, error) {
	tx, err := bs.db.Begin(false)
	if err != nil {
		return 0, err
	}
	defer tx.Rollback()
	bites := tx.Bucket(entriesBucket).Get(uint64ToBytes(i))
	if bites == nil || len(bites) == 0 {
		return 0, nil
	}
	entry := &raftpb.Entry{}
	err = proto.Unmarshal(bites, entry)
	if err != nil {
		return 0, err
	}
	return entry.Term, nil
}
func ( bs * boltStorage ) Term ( i uint64 ) ( uint64 , error ) { tx , err := bs . db . Begin ( false ) if err != nil { return 0 , err } defer tx . Rollback ( ) bites := tx . Bucket ( entriesBucket ) . Get ( uint64ToBytes ( i ) ) if bites == nil || len ( bites ) == 0 { return 0 , nil } entry := & raftpb . Entry { } err = proto . Unmarshal ( bites , entry ) if err != nil { return 0 , err } return entry . Term , nil }
Term returns the term of entry i, which must be in the range
[FirstIndex()-1, LastIndex()].
Term returns the term of entry i which must be in the range [ FirstIndex () - 1 LastIndex () ] .
// return 0, raft.ErrUnavailable