func (bs *boltStorage) dropLogEntriesBeforeIndex(index uint64) error {
	var key []byte
	var err error

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

	defer tx.Rollback()
	c := tx.Bucket(entriesBucket).Cursor()
	// find index
	c.Seek(uint64ToBytes(index))
	// move to the previous key
	// and start deleteing
	key, _ = c.Prev()

	for key != nil {
		err = c.Delete()
		if err != nil {
			bs.logger.Errorf("Couldn't delete key: %d", bytesToUint64(key))
		}
		key, _ = c.Prev()
	}

	err = tx.Commit()
	if err != nil {
		return err
	}

	return nil
}
// deletes all log entries older than the index provided
deletes all log entries older than the index provided
// deletes all log entries older than the index provided
func (bs *boltStorage) dropLogEntriesBeforeIndex(index uint64) error {
	var key []byte
	var err error
	tx, err := bs.db.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()
	c := tx.Bucket(entriesBucket).Cursor()
	c.Seek(uint64ToBytes(index))
	key, _ = c.Prev()
	for key != nil {
		err = c.Delete()
		if err != nil {
			bs.logger.Errorf("Couldn't delete key: %d", bytesToUint64(key))
		}
		key, _ = c.Prev()
	}
	err = tx.Commit()
	if err != nil {
		return err
	}
	return nil
}
func ( bs * boltStorage ) dropLogEntriesBeforeIndex ( index uint64 ) error { var key [ ] byte var err error tx , err := bs . db . Begin ( true ) if err != nil { return err } defer tx . Rollback ( ) c := tx . Bucket ( entriesBucket ) . Cursor ( ) c . Seek ( uint64ToBytes ( index ) ) key , _ = c . Prev ( ) for key != nil { err = c . Delete ( ) if err != nil { bs . logger . Errorf ( " " , bytesToUint64 ( key ) ) } key , _ = c . Prev ( ) } err = tx . Commit ( ) if err != nil { return err } return nil }
deletes all log entries older than the index provided
deletes all log entries older than the index provided
// find index // move to the previous key // and start deleteing