Documentation ¶
Index ¶
- Constants
- func NewWithLIB(libID bstream.BlockRef, h bstream.Handler)
- type Block
- type ForkDB
- func (f *ForkDB) AddLink(blockRef, previousRef bstream.BlockRef, obj interface{}) (exists bool)
- func (f *ForkDB) BlockForID(blockID string) *Block
- func (f *ForkDB) BlockInCurrentChain(startAtBlock bstream.BlockRef, blockNum uint64) bstream.BlockRef
- func (f *ForkDB) ChainSwitchSegments(oldHeadBlockID, newHeadsPreviousID string) (undo []string, redo []string)
- func (f *ForkDB) ClonedLinks() (out map[string]string, nums map[string]uint64)
- func (f *ForkDB) Exists(blockID string) bool
- func (f *ForkDB) HasLIB() bool
- func (f *ForkDB) HasNewIrreversibleSegment(newLIB bstream.BlockRef) (hasNew bool, irreversibleSegment, staleBlocks []*Block)
- func (f *ForkDB) InitLIB(ref bstream.BlockRef)
- func (f *ForkDB) IsBehindLIB(blockNum uint64) bool
- func (f *ForkDB) LIBID() string
- func (f *ForkDB) LIBNum() uint64
- func (f *ForkDB) MoveLIB(blockRef bstream.BlockRef) (purgedBlocks []*Block)
- func (f *ForkDB) ReversibleSegment(upToBlock bstream.BlockRef) (blocks []*Block)
- func (f *ForkDB) SetName(name string)
- func (f *ForkDB) TrySetLIB(headRef, previousRef bstream.BlockRef, libNum uint64)
- type Forkable
- type ForkableBlock
- type ForkableObject
- type IrreversibleBlockIDGate
- type IrreversibleBlockNumGate
- type Option
- func EnsureAllBlocksTriggerLongestChain() Option
- func EnsureBlockFlows(blockRef bstream.BlockRef) Option
- func WithExclusiveLIB(irreversibleBlock bstream.BlockRef) Option
- func WithFilters(steps StepType) Option
- func WithInclusiveLIB(irreversibleBlock bstream.BlockRef) Option
- func WithName(name string) Option
- type StepType
Constants ¶
const ( StepNew = StepType(1 << iota) //1 First time we're seeing this block StepUndo //2 We are undoing this block (it was done previously) StepRedo //4 We are redoing this block (it was done previously) StepHandoff //8 The block passed a handoff from one producer to another StepIrreversible //16 This block passed the LIB barrier and is in chain StepStalled //32 This block passed the LIB and is definitely forked out StepsAll = StepType(StepNew | StepUndo | StepRedo | StepHandoff | StepIrreversible | StepStalled) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ForkDB ¶
type ForkDB struct {
// contains filtered or unexported fields
}
ForkDB holds the graph of block headBlockID to previous block.
func (*ForkDB) BlockForID ¶
func (*ForkDB) BlockInCurrentChain ¶
func (f *ForkDB) BlockInCurrentChain(startAtBlock bstream.BlockRef, blockNum uint64) bstream.BlockRef
BlockInCurrentChain finds the block_id at height `blockNum` under the requested `startAtBlockID` base block. Passing the head block id as `startAtBlockID` will tell you if the block num is part of the longuest chain.
func (*ForkDB) ChainSwitchSegments ¶
func (f *ForkDB) ChainSwitchSegments(oldHeadBlockID, newHeadsPreviousID string) (undo []string, redo []string)
ChainSwitchSegments returns the list of block IDs that should be `undo`ne (in reverse chain order) and the list of blocks that should be `redo`ne (in chain order) for `blockID` (linking to `previousID`) to become the longest chain.
This assumes you are querying for something that *is* the longest chain (or the to-become longest chain).
func (*ForkDB) ClonedLinks ¶
CloneLinks retrieves a snapshot of the links in the ForkDB. Used only in ForkViewerin `eosws`.
func (*ForkDB) HasNewIrreversibleSegment ¶
func (f *ForkDB) HasNewIrreversibleSegment(newLIB bstream.BlockRef) (hasNew bool, irreversibleSegment, staleBlocks []*Block)
HasNewIrreversibleSegment returns segments upon psasing the newDposLIBID that are irreversible and stale. If there was no new segment, `hasNew` will be false. WARN: this method can only be called when `HasLIB()` is true. Otherwise, it panics.
func (*ForkDB) IsBehindLIB ¶
func (*ForkDB) ReversibleSegment ¶
ReversibleSegment returns the blocks between the previous irreversible Block ID and the given block ID. The LIB is excluded and the given block ID is included in the results.
Do not call this function is the .HasLIB() is false, as the result would make no sense.
WARN: if the segment is broken by some unlinkable blocks, the return value is `nil`.
type ForkableBlock ¶
type ForkableObject ¶
type ForkableObject struct { Step StepType HandoffCount int // The three following fields are filled when handling multi-block steps, like when passing Irreversibile segments, the whole segment is represented in here. StepCount int // Total number of steps in multi-block steps. StepIndex int // Index for the current block StepBlocks []*bstream.PreprocessedBlock // You can decide to process them when StepCount == StepIndex +1 or when StepIndex == 0 only. ForkDB *ForkDB // ForkDB is a reference to the `Forkable`'s ForkDB instance. Provided you don't use it in goroutines, it is safe for use in `ProcessBlock` calls. // Object that was returned by PreprocessBlock(). Could be nil Obj interface{} }
type IrreversibleBlockIDGate ¶
type IrreversibleBlockIDGate struct { Name string MaxHoldOff int // contains filtered or unexported fields }
This gate lets all blocks through once the target block ID has passed AS IRREVERSIBLE
func (*IrreversibleBlockIDGate) ProcessBlock ¶
func (g *IrreversibleBlockIDGate) ProcessBlock(blk *bstream.Block, obj interface{}) error
type IrreversibleBlockNumGate ¶
type IrreversibleBlockNumGate struct { Name string MaxHoldOff int // contains filtered or unexported fields }
This gate lets all blocks through once the target blocknum has passed AS IRREVERSIBLE
func (*IrreversibleBlockNumGate) ProcessBlock ¶
func (g *IrreversibleBlockNumGate) ProcessBlock(blk *bstream.Block, obj interface{}) error
type Option ¶
type Option func(f *Forkable)
func EnsureAllBlocksTriggerLongestChain ¶
func EnsureAllBlocksTriggerLongestChain() Option
EnsureAllBlocksTriggerLongestChain will force every block to be considered as the longest chain, therefore making it appear as New at least once. The only edge case is if there is a hole between a block and LIB when it is received, and it is forked out: in this case, that block would never appear. It is extremely unlikely to happen, because incoming blocks should be linkable, and blocks that are not forked out will eventually be processed anyway.
func EnsureBlockFlows ¶
func WithExclusiveLIB ¶
func WithFilters ¶
WithFilters choses the steps we want to pass through the sub handler. It defaults to StepsAll upon creation.