syncer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadySynced is reported when syncer is synced.
	ErrAlreadySynced = fmt.Errorf("already synced")
	// ErrNotSynced is reported when syncer is not synced yet.
	ErrNotSynced = fmt.Errorf("not synced yet")
	// ErrGenesisBlockReached is reported when genesis block reached.
	ErrGenesisBlockReached = fmt.Errorf("genesis block reached")
	// ErrInvalidBlockOrder is reported when SyncBlocks receives unordered
	// blocks.
	ErrInvalidBlockOrder = fmt.Errorf("invalid block order")
	// ErrInvalidSyncingHeight raised when the blocks to sync is not following
	// the compaction chain tip in database.
	ErrInvalidSyncingHeight = fmt.Errorf("invalid syncing height")
)

Functions

This section is empty.

Types

type Consensus

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

Consensus is for syncing consensus module.

func NewConsensus

func NewConsensus(
	initHeight uint64,
	dMoment time.Time,
	app core.Application,
	gov core.Governance,
	db db.Database,
	network core.Network,
	prv crypto.PrivateKey,
	logger common.Logger) *Consensus

NewConsensus creates an instance for Consensus (syncer consensus).

func (*Consensus) ForceSync

func (con *Consensus) ForceSync(lastPos types.Position, skip bool)

ForceSync forces syncer to become synced.

func (*Consensus) GetSyncedConsensus

func (con *Consensus) GetSyncedConsensus() (*core.Consensus, error)

GetSyncedConsensus returns the core.Consensus instance after synced.

func (*Consensus) SyncBlocks

func (con *Consensus) SyncBlocks(
	blocks []*types.Block, latest bool) (synced bool, err error)

SyncBlocks syncs blocks from compaction chain, latest is true if the caller regards the blocks are the latest ones. Notice that latest can be true for many times. NOTICE: parameter "blocks" should be consecutive in compaction height. NOTICE: this method is not expected to be called concurrently.

type WatchCat

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

WatchCat is reponsible for signaling if syncer object should be terminated.

func NewWatchCat

func NewWatchCat(
	recovery core.Recovery,
	configReader configReader,
	polling time.Duration,
	timeout time.Duration,
	logger common.Logger) *WatchCat

NewWatchCat creats a new WatchCat 🐱 object.

func (*WatchCat) Feed

func (wc *WatchCat) Feed(position types.Position)

Feed the WatchCat so it won't produce the termination signal.

func (*WatchCat) LastPosition

func (wc *WatchCat) LastPosition() types.Position

LastPosition returns the last position for recovery.

func (*WatchCat) Meow

func (wc *WatchCat) Meow() <-chan struct{}

Meow return a closed channel if syncer should be terminated.

func (*WatchCat) Start

func (wc *WatchCat) Start()

Start the WatchCat.

func (*WatchCat) Stop

func (wc *WatchCat) Stop()

Stop the WatchCat.

Jump to

Keyboard shortcuts

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