func (bs *boltStorage) Entries(lo, hi, maxByteSize uint64) ([]raftpb.Entry, error) {
	min := uint64ToBytes(lo)
	max := uint64ToBytes(hi)
	entries := make([]raftpb.Entry, hi-lo)

	tx, err := bs.db.Begin(false)
	if err != nil {
		return nil, err
	}

	defer tx.Rollback()
	c := tx.Bucket(entriesBucket).Cursor()

	idx := 0
	runningByteSize := uint64(0)
	// loop over all keys excluding (!!!) the high key
	for k, v := c.Seek(min); k != nil && bytes.Compare(k, max) < 0; k, v = c.Next() {
		// we need to honor the max byte size parameter
		// but in any case at least return one (if one is present)
		if uint64(len(v))+runningByteSize > maxByteSize && idx > 0 {
			break
		}

		// add byte size to running counter
		runningByteSize += uint64(len(v))

		// go about my business of deserializing the entry
		e := &raftpb.Entry{}
		err = proto.Unmarshal(v, e)
		if err != nil {
			bs.logger.Errorf("Can't unmarshal: %s", err.Error())
			return nil, err
		}

		entries[idx] = *e
		idx++
	}

	return entries[:idx], nil
}
// Entries returns a slice of log entries in the range [lo,hi).
// MaxSize limits the total size of the log entries returned, but
// Entries returns at least one entry if any.
Entries returns a slice of log entries in the range [lo,hi).
MaxSize limits the total size of the log entries returned, but
Entries returns at least one entry if any.
// Entries returns a slice of log entries in the range [ lo hi ) . // MaxSize limits the total size of the log entries returned but // Entries returns at least one entry if any .
func (bs *boltStorage) Entries(lo, hi, maxByteSize uint64) ([]raftpb.Entry, error) {
	min := uint64ToBytes(lo)
	max := uint64ToBytes(hi)
	entries := make([]raftpb.Entry, hi-lo)
	tx, err := bs.db.Begin(false)
	if err != nil {
		return nil, err
	}
	defer tx.Rollback()
	c := tx.Bucket(entriesBucket).Cursor()
	idx := 0
	runningByteSize := uint64(0)
	for k, v := c.Seek(min); k != nil && bytes.Compare(k, max) < 0; k, v = c.Next() {
		if uint64(len(v))+runningByteSize > maxByteSize && idx > 0 {
			break
		}
		runningByteSize += uint64(len(v))
		e := &raftpb.Entry{}
		err = proto.Unmarshal(v, e)
		if err != nil {
			bs.logger.Errorf("Can't unmarshal: %s", err.Error())
			return nil, err
		}
		entries[idx] = *e
		idx++
	}
	return entries[:idx], nil
}
func ( bs * boltStorage ) Entries ( lo , hi , maxByteSize uint64 ) ( [ ] raftpb . Entry , error ) { min := uint64ToBytes ( lo ) max := uint64ToBytes ( hi ) entries := make ( [ ] raftpb . Entry , hi - lo ) tx , err := bs . db . Begin ( false ) if err != nil { return nil , err } defer tx . Rollback ( ) c := tx . Bucket ( entriesBucket ) . Cursor ( ) idx := 0 runningByteSize := uint64 ( 0 ) for k , v := c . Seek ( min ) ; k != nil && bytes . Compare ( k , max ) < 0 ; k , v = c . Next ( ) { if uint64 ( len ( v ) ) + runningByteSize > maxByteSize && idx > 0 { break } runningByteSize += uint64 ( len ( v ) ) e := & raftpb . Entry { } err = proto . Unmarshal ( v , e ) if err != nil { bs . logger . Errorf ( " " , err . Error ( ) ) return nil , err } entries [ idx ] = * e idx ++ } return entries [ : idx ] , nil }
Entries returns a slice of log entries in the range [lo,hi).
Entries returns a slice of log entries in the range [ lo hi ) .
// loop over all keys excluding (!!!) the high key // we need to honor the max byte size parameter // but in any case at least return one (if one is present) // add byte size to running counter // go about my business of deserializing the entry