github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/chunkDataPacks.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  	badgermodel "github.com/onflow/flow-go/storage/badger/model"
     8  )
     9  
    10  // InsertChunkDataPack inserts a chunk data pack keyed by chunk ID.
    11  func InsertChunkDataPack(c *badgermodel.StoredChunkDataPack) func(*badger.Txn) error {
    12  	return insert(makePrefix(codeChunkDataPack, c.ChunkID), c)
    13  }
    14  
    15  // BatchInsertChunkDataPack inserts a chunk data pack keyed by chunk ID into a batch
    16  func BatchInsertChunkDataPack(c *badgermodel.StoredChunkDataPack) func(batch *badger.WriteBatch) error {
    17  	return batchWrite(makePrefix(codeChunkDataPack, c.ChunkID), c)
    18  }
    19  
    20  // BatchRemoveChunkDataPack removes a chunk data pack keyed by chunk ID, in a batch.
    21  // No errors are expected during normal operation, even if no entries are matched.
    22  // If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned.
    23  func BatchRemoveChunkDataPack(chunkID flow.Identifier) func(batch *badger.WriteBatch) error {
    24  	return batchRemove(makePrefix(codeChunkDataPack, chunkID))
    25  }
    26  
    27  // RetrieveChunkDataPack retrieves a chunk data pack by chunk ID.
    28  func RetrieveChunkDataPack(chunkID flow.Identifier, c *badgermodel.StoredChunkDataPack) func(*badger.Txn) error {
    29  	return retrieve(makePrefix(codeChunkDataPack, chunkID), c)
    30  }
    31  
    32  // RemoveChunkDataPack removes the chunk data pack with the given chunk ID.
    33  func RemoveChunkDataPack(chunkID flow.Identifier) func(*badger.Txn) error {
    34  	return remove(makePrefix(codeChunkDataPack, chunkID))
    35  }