indexer

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2020 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAddOutOfOrder = errors.New("added tipset height lower than current head")
View Source
var ErrCacheEmpty = errors.New("cache empty")
View Source
var ErrRevertOutOfOrder = errors.New("reverted tipset does not match current head")

Functions

This section is empty.

Types

type ChainHeadIndexer

type ChainHeadIndexer struct {
	// contains filtered or unexported fields
}

ChainHeadIndexer is a task that indexes blocks by following the chain head.

func NewChainHeadIndexer

func NewChainHeadIndexer(d *storage.Database, node lens.API, confidence int) *ChainHeadIndexer

NewChainHeadIndexer creates a new ChainHeadIndexer. confidence sets the number of tipsets that will be held in a cache awaiting possible reversion. Tipsets will be written to the database when they are evicted from the cache due to incoming later tipsets.

func (*ChainHeadIndexer) Run

func (c *ChainHeadIndexer) Run(ctx context.Context) error

Run starts following the chain head and blocks until the context is done or an error occurs.

type ChainHistoryIndexer

type ChainHistoryIndexer struct {
	// contains filtered or unexported fields
}

ChainHistoryIndexer is a task that indexes blocks by following the chain history.

func NewChainHistoryIndexer

func NewChainHistoryIndexer(d *storage.Database, node lens.API) *ChainHistoryIndexer

func (*ChainHistoryIndexer) Run

Run starts walking the chain history and continues until the context is done or the start of the chain is reached.

func (*ChainHistoryIndexer) WalkChain

func (c *ChainHistoryIndexer) WalkChain(ctx context.Context, maxHeight int64) error

type TipSetCache

type TipSetCache struct {
	// contains filtered or unexported fields
}

TipSetCache is a cache of recent tipsets that can keep track of reversions. Inspired by tipSetCache in Lotus chain/events package.

func NewTipSetCache

func NewTipSetCache(size int) *TipSetCache

func (*TipSetCache) Add

func (c *TipSetCache) Add(ts *types.TipSet) (*types.TipSet, error)

Add adds a new tipset which becomes the new head of the cache. If the buffer is full, the tail being evicted is also returned.

func (*TipSetCache) Head

func (c *TipSetCache) Head() (*types.TipSet, error)

Head returns the tipset at the head of the cache.

func (*TipSetCache) Height

func (c *TipSetCache) Height() abi.ChainEpoch

Height returns the height of the current head or zero if the cache is empty.

func (*TipSetCache) Len

func (c *TipSetCache) Len() int

Len returns the number of tipsets in the cache. This will never exceed the size of the cache.

func (*TipSetCache) Reset

func (c *TipSetCache) Reset()

Reset removes all tipsets from the cache

func (*TipSetCache) Revert

func (c *TipSetCache) Revert(ts *types.TipSet) error

Revert removes the head tipset

func (*TipSetCache) SetCurrent

func (c *TipSetCache) SetCurrent(ts *types.TipSet) error

SetCurrent replaces the current head

func (*TipSetCache) Tail

func (c *TipSetCache) Tail() (*types.TipSet, error)

Tail returns the tipset at the tail of the cache.

func (*TipSetCache) TailHeight

func (c *TipSetCache) TailHeight() abi.ChainEpoch

TailHeight returns the height of the current tail or zero if the cache is empty.

type UnindexedBlockData

type UnindexedBlockData struct {
	// contains filtered or unexported fields
}

func NewUnindexedBlockData

func NewUnindexedBlockData() *UnindexedBlockData

func (*UnindexedBlockData) AddBlock

func (u *UnindexedBlockData) AddBlock(bh *types.BlockHeader)

func (*UnindexedBlockData) AddTipSet

func (u *UnindexedBlockData) AddTipSet(ts *types.TipSet)

func (*UnindexedBlockData) Height

func (u *UnindexedBlockData) Height() abi.ChainEpoch

func (*UnindexedBlockData) MarkSeen

func (u *UnindexedBlockData) MarkSeen(tsk types.TipSetKey)

func (*UnindexedBlockData) Persist

func (u *UnindexedBlockData) Persist(ctx context.Context, db *pg.DB) error

func (*UnindexedBlockData) Reset

func (u *UnindexedBlockData) Reset()

Reset clears the unindexed data but keeps the history of which cids have been seen.

func (*UnindexedBlockData) Seen

func (u *UnindexedBlockData) Seen(tsk types.TipSetKey) bool

func (*UnindexedBlockData) Size

func (u *UnindexedBlockData) Size() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL