MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / DeleteRange

Method DeleteRange

lib/datastore/boltdb.go:160–178  ·  view source on GitHub ↗

DeleteRange is a method on BoltDbStore that deletes a range of log entries

(min, max uint64)

Source from the content-addressed store, hash-verified

158
159// DeleteRange is a method on BoltDbStore that deletes a range of log entries
160func (ds *BoltDbStore) DeleteRange(min, max uint64) error {
161 tx, err := ds.conn.Begin(true) // Start a read-write transaction
162 if err != nil {
163 return err
164 }
165 key := uint64ToBytes(min)
166 defer check(tx.Rollback)
167 curs := tx.Bucket(bucketLogs).Cursor()
168 for k, _ := curs.Seek(key[:]); k != nil; k, _ = curs.Next() {
169 // If we reach the max, we are done
170 if binary.BigEndian.Uint64(k) > max {
171 break
172 }
173 if err := curs.Delete(); err != nil {
174 return err
175 }
176 }
177 return tx.Commit()
178}
179
180func (ds *BoltDbStore) Set(key []byte, val []byte) error {
181 if len(key) == 0 {

Callers

nothing calls this directly

Calls 6

uint64ToBytesFunction · 0.85
checkFunction · 0.85
CommitMethod · 0.80
SeekMethod · 0.65
NextMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected