github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/version_beacon.go (about) 1 package operation 2 3 import ( 4 "github.com/dgraph-io/badger/v2" 5 6 "github.com/onflow/flow-go/model/flow" 7 ) 8 9 // IndexVersionBeaconByHeight stores a sealed version beacon indexed by 10 // flow.SealedVersionBeacon.SealHeight. 11 // 12 // No errors are expected during normal operation. 13 func IndexVersionBeaconByHeight( 14 beacon *flow.SealedVersionBeacon, 15 ) func(*badger.Txn) error { 16 return upsert(makePrefix(codeVersionBeacon, beacon.SealHeight), beacon) 17 } 18 19 // LookupLastVersionBeaconByHeight finds the highest flow.VersionBeacon but no higher 20 // than maxHeight. Returns storage.ErrNotFound if no version beacon exists at or below 21 // the given height. 22 func LookupLastVersionBeaconByHeight( 23 maxHeight uint64, 24 versionBeacon *flow.SealedVersionBeacon, 25 ) func(*badger.Txn) error { 26 return findHighestAtOrBelow( 27 makePrefix(codeVersionBeacon), 28 maxHeight, 29 versionBeacon, 30 ) 31 }