GetMinTransientBlkHt returns the lowest block height remaining in transient store
()
| 476 | |
| 477 | // GetMinTransientBlkHt returns the lowest block height remaining in transient store |
| 478 | func (s *Store) GetMinTransientBlkHt() (uint64, error) { |
| 479 | // Current approach performs a range query on purgeIndex with startKey |
| 480 | // as 0 (i.e., blockHeight) and returns the first key which denotes |
| 481 | // the lowest block height remaining in transient store. An alternative approach |
| 482 | // is to explicitly store the minBlockHeight in the transientStore. |
| 483 | startKey := createPurgeIndexByHeightRangeStartKey(0) |
| 484 | iter, err := s.db.GetIterator(startKey, nil) |
| 485 | if err != nil { |
| 486 | return 0, err |
| 487 | } |
| 488 | defer iter.Release() |
| 489 | // Fetch the minimum transient block height |
| 490 | if iter.Next() { |
| 491 | dbKey := iter.Key() |
| 492 | _, _, blockHeight, err := splitCompositeKeyOfPurgeIndexByHeight(dbKey) |
| 493 | return blockHeight, err |
| 494 | } |
| 495 | // Returning an error may not be the right thing to do here. May be |
| 496 | // return a bool. -1 is not possible due to unsigned int as first |
| 497 | // return value |
| 498 | return 0, ErrStoreEmpty |
| 499 | } |
| 500 | |
| 501 | func (s *Store) Shutdown() { |
| 502 | // do nothing because shared db is used |