Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIndexedBlockIterator ¶
func NewIndexedBlockIterator( getBlockIDByIndex func(uint64) (blockID flow.Identifier, indexed bool, exception error), progress module.IteratorStateWriter, iterRange module.IteratorRange, ) module.BlockIterator
caller must ensure that both iterRange.Start and iterRange.End are finalized
Types ¶
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator creates block iterators. a block iterator iterates through a saved index to the latest block. after iterating through all the blocks in the range, the iterator can be discarded. a new block iterator can be created to iterate through the next range.
func NewCreator ¶
func NewCreator( getBlockIDByIndex func(uint64) (blockID flow.Identifier, indexed bool, exception error), progressStorage storage.ConsumerProgressInitializer, root uint64, latest func() (uint64, error), ) (*Creator, error)
NewCreator creates a block iterator that iterates through blocks by index. the root is the block index to start iterating from. (it could either root height or root view) the latest is a function that returns the latest block index. since latest is a function, the caller can reuse the creator to create block iterator one after another to iterate from the root to the latest, and from last iterated to the new latest.
func NewHeightBasedCreator ¶
func NewHeightBasedCreator( getBlockIDByHeight func(height uint64) (flow.Identifier, error), progress storage.ConsumerProgressInitializer, root *flow.Header, latest func() (*flow.Header, error), ) (*Creator, error)
NewHeightBasedCreator creates a block iterator that iterates through blocks from root to the latest (either finalized or sealed) by height.
func NewViewBasedCreator ¶
func NewViewBasedCreator( getBlockIDByView func(view uint64) (blockID flow.Identifier, viewIndexed bool, exception error), progress storage.ConsumerProgressInitializer, root *flow.Header, latest func() (*flow.Header, error), ) (*Creator, error)
NewViewBasedCreator creates a block iterator that iterates through blocks from root to the latest (either finalized or sealed) by view. since view has gaps, the iterator will skip views that have no blocks.
type IndexedBlockIterator ¶
type IndexedBlockIterator struct {
// contains filtered or unexported fields
}
IndexedBlockIterator is a block iterator that iterates over blocks by height or view when index is height, it iterates from lower height to higher height when index is view, it iterates from lower view to higher view caller must ensure that the range is finalized, otherwise the iteration might miss some blocks it's not concurrent safe, so don't use it in multiple goroutines
func (*IndexedBlockIterator) Checkpoint ¶
func (b *IndexedBlockIterator) Checkpoint() (uint64, error)
Checkpoint saves the iteration progress to storage make sure to call this after all the blocks for processing the block IDs returned by Next() are completed.
func (*IndexedBlockIterator) Next ¶
func (b *IndexedBlockIterator) Next() (flow.Identifier, bool, error)
Next returns the next block ID in the iteration it iterates from lower index to higher index. Note: this method is not concurrent-safe
type PersistentIteratorState ¶
type PersistentIteratorState struct {
// contains filtered or unexported fields
}
PersistentIteratorState stores the state of the iterator in a persistent storage
func NewPersistentIteratorState ¶
func NewPersistentIteratorState(initializer storage.ConsumerProgressInitializer, root uint64, latest func() (uint64, error)) (*PersistentIteratorState, error)
func (*PersistentIteratorState) LoadState ¶
func (n *PersistentIteratorState) LoadState() (uint64, error)
func (*PersistentIteratorState) NextRange ¶
func (n *PersistentIteratorState) NextRange() (rg module.IteratorRange, hasNext bool, exception error)
NextRange returns the next range of blocks to iterate over the range is inclusive, and the end is the latest block if there is no block to iterate, hasNext is false
func (*PersistentIteratorState) SaveState ¶
func (n *PersistentIteratorState) SaveState(next uint64) error