github.com/koko1123/flow-go-1@v0.29.6/storage/headers.go (about) 1 // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED 2 3 package storage 4 5 import ( 6 "github.com/koko1123/flow-go-1/model/flow" 7 ) 8 9 // Headers represents persistent storage for blocks. 10 type Headers interface { 11 12 // Store will store a header. 13 Store(header *flow.Header) error 14 15 // ByBlockID returns the header with the given ID. It is available for 16 // finalized and ambiguous blocks. 17 ByBlockID(blockID flow.Identifier) (*flow.Header, error) 18 19 // ByHeight returns the block with the given number. It is only available 20 // for finalized blocks. 21 ByHeight(height uint64) (*flow.Header, error) 22 23 // ByParentID finds all children for the given parent block. The returned headers 24 // might be unfinalized; if there is more than one, at least one of them has to 25 // be unfinalized. 26 ByParentID(parentID flow.Identifier) ([]*flow.Header, error) 27 28 // IndexByChunkID indexes block ID by chunk ID. 29 IndexByChunkID(headerID, chunkID flow.Identifier) error 30 31 // BatchIndexByChunkID indexes block ID by chunk ID in a given batch. 32 BatchIndexByChunkID(headerID, chunkID flow.Identifier, batch BatchStorage) error 33 34 // IDByChunkID finds the ID of the block corresponding to given chunk ID. 35 IDByChunkID(chunkID flow.Identifier) (flow.Identifier, error) 36 37 // BatchRemoveChunkBlockIndexByChunkID removes block to chunk index entry keyed by a blockID in a provided batch 38 // No errors are expected during normal operation, even if no entries are matched. 39 // If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned. 40 BatchRemoveChunkBlockIndexByChunkID(chunkID flow.Identifier, batch BatchStorage) error 41 }