github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/spork.go (about)

     1  package operation
     2  
     3  import (
     4  	"github.com/dgraph-io/badger/v3"
     5  
     6  	"github.com/koko1123/flow-go-1/model/flow"
     7  )
     8  
     9  // InsertSporkID inserts the spork ID for the present spork. A single database
    10  // and protocol state instance spans at most one spork, so this is inserted
    11  // exactly once, when bootstrapping the state.
    12  func InsertSporkID(sporkID flow.Identifier) func(*badger.Txn) error {
    13  	return insert(makePrefix(codeSporkID), sporkID)
    14  }
    15  
    16  // RetrieveSporkID retrieves the spork ID for the present spork.
    17  func RetrieveSporkID(sporkID *flow.Identifier) func(*badger.Txn) error {
    18  	return retrieve(makePrefix(codeSporkID), sporkID)
    19  }
    20  
    21  // InsertProtocolVersion inserts the protocol version for the present spork.
    22  // A single database and protocol state instance spans at most one spork, and
    23  // a spork has exactly one protocol version for its duration, so this is
    24  // inserted exactly once, when bootstrapping the state.
    25  func InsertProtocolVersion(version uint) func(*badger.Txn) error {
    26  	return insert(makePrefix(codeProtocolVersion), version)
    27  }
    28  
    29  // RetrieveProtocolVersion retrieves the protocol version for the present spork.
    30  func RetrieveProtocolVersion(version *uint) func(*badger.Txn) error {
    31  	return retrieve(makePrefix(codeProtocolVersion), version)
    32  }