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

Method FirstIndex

lib/datastore/boltdb.go:72–88  ·  view source on GitHub ↗

FirstIndex is a method on BoltDbStore that returns the first index in the log

()

Source from the content-addressed store, hash-verified

70
71// FirstIndex is a method on BoltDbStore that returns the first index in the log
72func (ds *BoltDbStore) FirstIndex() (uint64, error) {
73 tx, err := ds.conn.Begin(false)
74 if err != nil {
75 return 0, err
76 }
77 defer check(tx.Rollback)
78 var (
79 key []byte
80 idx uint64
81 )
82 curs := tx.Bucket(bucketLogs).Cursor()
83 key, _ = curs.First() // Retrieve the first key in the bucket
84 if key != nil {
85 idx = binary.BigEndian.Uint64(key)
86 }
87 return idx, nil
88}
89
90// LastIndex is a method on BoltDbStore that returns the last index in the log
91func (ds *BoltDbStore) LastIndex() (uint64, error) {

Callers

nothing calls this directly

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected