MCPcopy
hub / github.com/hyperledger/fabric / GetMinTransientBlkHt

Method GetMinTransientBlkHt

core/transientstore/store.go:478–499  ·  view source on GitHub ↗

GetMinTransientBlkHt returns the lowest block height remaining in transient store

()

Source from the content-addressed store, hash-verified

476
477// GetMinTransientBlkHt returns the lowest block height remaining in transient store
478func (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
501func (s *Store) Shutdown() {
502 // do nothing because shared db is used

Callers 5

verifyStoreDroppedFunction · 0.80
TestIteratorErrorCasesFunction · 0.80
TestDeleteTransientStoreFunction · 0.80

Calls 6

ReleaseMethod · 0.65
NextMethod · 0.65
KeyMethod · 0.65
GetIteratorMethod · 0.45

Tested by 5

verifyStoreDroppedFunction · 0.64
TestIteratorErrorCasesFunction · 0.64
TestDeleteTransientStoreFunction · 0.64