FirstIndex is a method on BoltDbStore that returns the first index in the log
()
| 70 | |
| 71 | // FirstIndex is a method on BoltDbStore that returns the first index in the log |
| 72 | func (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 |
| 91 | func (ds *BoltDbStore) LastIndex() (uint64, error) { |