Documentation ¶
Index ¶
- func TraverseBackward(headers storage.Headers, forkHead flow.Identifier, visitor onVisitBlock, ...) error
- func TraverseForward(headers storage.Headers, forkHead flow.Identifier, visitor onVisitBlock, ...) error
- type ExcludingBlock
- type ExcludingHeight
- type IncludingBlock
- type IncludingHeight
- type Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TraverseBackward ¶
func TraverseBackward(headers storage.Headers, forkHead flow.Identifier, visitor onVisitBlock, terminal Terminal) error
TraverseBackward traverses the given fork (specified by block ID `forkHead`) in the order of decreasing height. The `terminal` defines when the traversal stops. The `visitor` callback is called for each block in this segment.
func TraverseForward ¶
func TraverseForward(headers storage.Headers, forkHead flow.Identifier, visitor onVisitBlock, terminal Terminal, ) error
TraverseForward traverses the given fork (specified by block ID `forkHead`) in the order of increasing height. The `terminal` defines when the traversal begins. The `visitor` callback is called for each block in this segment.
Types ¶
type ExcludingBlock ¶
type ExcludingBlock flow.Identifier
ExcludingBlock returns a Terminal implementation where we explicitly specify the ID of the lowest block that should _not_ be visited anymore
func (ExcludingBlock) ConfirmTerminalReached ¶
func (t ExcludingBlock) ConfirmTerminalReached(headers storage.Headers, lowestVisitedBlock *flow.Header) error
ConfirmTerminalReached is a self-consistency check that the lowest visited block is in fact the expected terminal.
func (ExcludingBlock) LowestHeightToVisit ¶
func (t ExcludingBlock) LowestHeightToVisit(headers storage.Headers) (uint64, error)
LowestHeightToVisit computes the height of the lowest block that should be visited
type ExcludingHeight ¶
type ExcludingHeight uint64
ExcludingHeight returns a Terminal implementation where we specify the Height of the lowest block that should _not_ be visited anymore
func (ExcludingHeight) ConfirmTerminalReached ¶
func (t ExcludingHeight) ConfirmTerminalReached(headers storage.Headers, lowestVisitedBlock *flow.Header) error
ConfirmTerminalReached is a self-consistency check that the lowest visited block is in fact the expected terminal.
func (ExcludingHeight) LowestHeightToVisit ¶
func (t ExcludingHeight) LowestHeightToVisit(storage.Headers) (uint64, error)
LowestHeightToVisit computes the height of the lowest block that should be visited
type IncludingBlock ¶
type IncludingBlock flow.Identifier
IncludingBlock returns a Terminal implementation where we explicitly specify the ID of the lowest block that should be visited
func (IncludingBlock) ConfirmTerminalReached ¶
func (t IncludingBlock) ConfirmTerminalReached(headers storage.Headers, lowestVisitedBlock *flow.Header) error
ConfirmTerminalReached is a self-consistency check that the lowest visited block is in fact the expected terminal.
func (IncludingBlock) LowestHeightToVisit ¶
func (t IncludingBlock) LowestHeightToVisit(headers storage.Headers) (uint64, error)
LowestHeightToVisit computes the height of the lowest block that should be visited
type IncludingHeight ¶
type IncludingHeight uint64
IncludingHeight returns a Terminal implementation where we specify the height of the lowest block that should be visited
func (IncludingHeight) ConfirmTerminalReached ¶
func (t IncludingHeight) ConfirmTerminalReached(headers storage.Headers, lowestVisitedBlock *flow.Header) error
ConfirmTerminalReached is a self-consistency check that the lowest visited block is in fact the expected terminal.
func (IncludingHeight) LowestHeightToVisit ¶
func (t IncludingHeight) LowestHeightToVisit(storage.Headers) (uint64, error)
LowestHeightToVisit computes the height of the lowest block that should be visited
type Terminal ¶
type Terminal interface { // LowestHeightToVisit computes the height of the lowest block that should be visited LowestHeightToVisit(headers storage.Headers) (uint64, error) // ConfirmTerminalReached is a self-consistency check that the lowest visited block is // in fact the expected terminal. ConfirmTerminalReached(headers storage.Headers, lowestVisitedBlock *flow.Header) error }
Terminal specifies the terminal condition for traversing a fork. It abstracts the precise termination condition for `TraverseBackward` and `TraverseForward`. Generally, when traversing a fork (in either direction), there are two distinct blocks:
- the `head` of the fork that should be traversed
- the `lowestBlock` in that fork, which should be included in the traversal
The traversal algorithm walks `head <--> lowestBlock` (in either direction).
There are a variety of ways to precisely specify `head` and `lowestBlock`:
- At least one block, `head` or `lowestBlock`, must be specified by its ID to unambiguously identify the fork that should be traversed.
- The other block an either be specified by ID or height.
- If both `head` and `lowestBlock` are specified by their ID, they must both be on the same fork.
Essentially it converts the termination condition into two statements:
- (i) The height of the lowest block that should be visited.
- (ii) A consistency check `ConfirmTerminalReached` for the lowest visited block. This check is predominantly useful in case both `head` and `lowestBlock` are specified by their ID. It allows to enforce that `head` and `lowestBlock` are both on the same fork and error otherwise. However, the precise implementation of `ConfirmTerminalReached` is left to the Terminal. Other, more elaborate conditions are possible.