github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/heights.go (about) 1 // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED 2 3 package operation 4 5 import ( 6 "github.com/dgraph-io/badger/v3" 7 ) 8 9 func InsertRootHeight(height uint64) func(*badger.Txn) error { 10 return insert(makePrefix(codeRootHeight), height) 11 } 12 13 func RetrieveRootHeight(height *uint64) func(*badger.Txn) error { 14 return retrieve(makePrefix(codeRootHeight), height) 15 } 16 17 func InsertFinalizedHeight(height uint64) func(*badger.Txn) error { 18 return insert(makePrefix(codeFinalizedHeight), height) 19 } 20 21 func UpdateFinalizedHeight(height uint64) func(*badger.Txn) error { 22 return update(makePrefix(codeFinalizedHeight), height) 23 } 24 25 func RetrieveFinalizedHeight(height *uint64) func(*badger.Txn) error { 26 return retrieve(makePrefix(codeFinalizedHeight), height) 27 } 28 29 func InsertSealedHeight(height uint64) func(*badger.Txn) error { 30 return insert(makePrefix(codeSealedHeight), height) 31 } 32 33 func UpdateSealedHeight(height uint64) func(*badger.Txn) error { 34 return update(makePrefix(codeSealedHeight), height) 35 } 36 37 func RetrieveSealedHeight(height *uint64) func(*badger.Txn) error { 38 return retrieve(makePrefix(codeSealedHeight), height) 39 } 40 41 // InsertLastCompleteBlockHeightIfNotExists inserts the last full block height if it is not already set. 42 // Calling this function multiple times is a no-op and returns no expected errors. 43 func InsertLastCompleteBlockHeightIfNotExists(height uint64) func(*badger.Txn) error { 44 return SkipDuplicates(InsertLastCompleteBlockHeight(height)) 45 } 46 47 func InsertLastCompleteBlockHeight(height uint64) func(*badger.Txn) error { 48 return insert(makePrefix(codeLastCompleteBlockHeight), height) 49 } 50 51 func UpdateLastCompleteBlockHeight(height uint64) func(*badger.Txn) error { 52 return update(makePrefix(codeLastCompleteBlockHeight), height) 53 } 54 55 func RetrieveLastCompleteBlockHeight(height *uint64) func(*badger.Txn) error { 56 return retrieve(makePrefix(codeLastCompleteBlockHeight), height) 57 }