sync

package
v1.0.50 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBlockIsNotSigned = errors.New("block is not signed")

ErrBlockIsNotSigned signals that the block is not signed

View Source
var ErrHigherNonceInBlock = errors.New("higher nonce in block")

ErrHigherNonceInBlock signals that the nonce in block is higher than what could exist in the current round

View Source
var ErrHigherRoundInBlock = errors.New("higher round in block")

ErrHigherRoundInBlock signals that the round index in block is higher than the current round of chronology

View Source
var ErrInvalidShardId = errors.New("invalid shard id")

ErrInvalidShardId signals that an invalid shard id has been provided

View Source
var ErrLowerNonceInBlock = errors.New("lower nonce in block")

ErrLowerNonceInBlock signals that the nonce in block is lower than the last check point nonce

View Source
var ErrLowerRoundInBlock = errors.New("lower round in block")

ErrLowerRoundInBlock signals that the round index in block is lower than the checkpoint round

View Source
var ErrNilHash = errors.New("nil hash")

ErrNilHash signals that a nil hash has been provided

View Source
var ErrNilHeader = errors.New("nil header")

ErrNilHeader signals that a nil header has been provided

View Source
var ErrNilNotarizedHeader = errors.New("nil notarized header")

ErrNilNotarizedHeader signals that an nil notarized header has been provided

View Source
var ErrRandomSeedNotValid = errors.New("random seed is not valid")

ErrRandomSeedNotValid signals that the random seed is not valid

View Source
var ErrRollBackBehindFinalHeader = errors.New("roll back behind final header is not permitted")

ErrRollBackBehindFinalHeader signals that a roll back behind final header has been attempted

Functions

func NewMetaForkDetector

func NewMetaForkDetector(
	rounder consensus.Rounder,
	blackListHandler process.BlackListHandler,
) (*metaForkDetector, error)

NewMetaForkDetector method creates a new metaForkDetector object

func NewShardForkDetector

func NewShardForkDetector(
	rounder consensus.Rounder,
	blackListHandler process.BlackListHandler,
) (*shardForkDetector, error)

NewShardForkDetector method creates a new shardForkDetector object

Types

type ErrSignedBlock

type ErrSignedBlock struct {
	CurrentNonce uint64
}

ErrSignedBlock signals that a block is signed

func (ErrSignedBlock) Error

func (err ErrSignedBlock) Error() string

type HdrInfo

type HdrInfo struct {
	Nonce uint64
	Hash  []byte
}

HdrInfo hold the data related to a header

type MetaBootstrap

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

MetaBootstrap implements the bootstrap mechanism

func NewMetaBootstrap

func NewMetaBootstrap(
	poolsHolder dataRetriever.MetaPoolsHolder,
	store dataRetriever.StorageService,
	blkc data.ChainHandler,
	rounder consensus.Rounder,
	blkExecutor process.BlockProcessor,
	waitTime time.Duration,
	hasher hashing.Hasher,
	marshalizer marshal.Marshalizer,
	forkDetector process.ForkDetector,
	resolversFinder dataRetriever.ResolversFinder,
	shardCoordinator sharding.Coordinator,
	accounts state.AccountsAdapter,
	blackListHandler process.BlackListHandler,
	networkWatcher process.NetworkConnectionWatcher,
	bootStorer process.BootStorer,
	storageBootstrapper process.BootstrapperFromStorage,
	requestedItemsHandler dataRetriever.RequestedItemsHandler,
) (*MetaBootstrap, error)

NewMetaBootstrap creates a new Bootstrap object

func (MetaBootstrap) AddSyncStateListener

func (boot MetaBootstrap) AddSyncStateListener(syncStateListener func(isSyncing bool))

AddSyncStateListener adds a syncStateListener that get notified each time the sync status of the node changes

func (*MetaBootstrap) IsInterfaceNil

func (boot *MetaBootstrap) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (MetaBootstrap) SetStatusHandler

func (boot MetaBootstrap) SetStatusHandler(handler core.AppStatusHandler) error

SetStatusHandler will set the instance of the AppStatusHandler

func (MetaBootstrap) ShouldSync added in v1.0.3

func (boot MetaBootstrap) ShouldSync() bool

ShouldSync method returns the sync state of the node. If it returns 'true', this means that the node is not synchronized yet and it has to continue the bootstrapping mechanism, otherwise the node is already synced and it can participate to the consensus, if it is in the jobDone group of this rounder. Note that when the node is not connected to the network, ShouldSync returns true but the SyncBlock is not automatically called

func (*MetaBootstrap) StartSync

func (boot *MetaBootstrap) StartSync()

StartSync method will start SyncBlocks as a go routine

func (MetaBootstrap) StopSync

func (boot MetaBootstrap) StopSync()

StopSync method will stop SyncBlocks

func (*MetaBootstrap) SyncBlock

func (boot *MetaBootstrap) SyncBlock() error

SyncBlock method actually does the synchronization. It requests the next block header from the pool and if it is not found there it will be requested from the network. After the header is received, it requests the block body in the same way(pool and than, if it is not found in the pool, from network). If either header and body are received the ProcessBlock and CommitBlock method will be called successively. These methods will execute the block and its transactions. Finally if everything works, the block will be committed in the blockchain, and all this mechanism will be reiterated for the next block.

type ShardBootstrap

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

ShardBootstrap implements the bootstrap mechanism

func NewShardBootstrap

func NewShardBootstrap(
	poolsHolder dataRetriever.PoolsHolder,
	store dataRetriever.StorageService,
	blkc data.ChainHandler,
	rounder consensus.Rounder,
	blkExecutor process.BlockProcessor,
	waitTime time.Duration,
	hasher hashing.Hasher,
	marshalizer marshal.Marshalizer,
	forkDetector process.ForkDetector,
	resolversFinder dataRetriever.ResolversFinder,
	shardCoordinator sharding.Coordinator,
	accounts state.AccountsAdapter,
	blackListHandler process.BlackListHandler,
	networkWatcher process.NetworkConnectionWatcher,
	bootStorer process.BootStorer,
	storageBootstrapper process.BootstrapperFromStorage,
	requestedItemsHandler dataRetriever.RequestedItemsHandler,
) (*ShardBootstrap, error)

NewShardBootstrap creates a new Bootstrap object

func (ShardBootstrap) AddSyncStateListener

func (boot ShardBootstrap) AddSyncStateListener(syncStateListener func(isSyncing bool))

AddSyncStateListener adds a syncStateListener that get notified each time the sync status of the node changes

func (*ShardBootstrap) IsInterfaceNil

func (boot *ShardBootstrap) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (ShardBootstrap) SetStatusHandler

func (boot ShardBootstrap) SetStatusHandler(handler core.AppStatusHandler) error

SetStatusHandler will set the instance of the AppStatusHandler

func (ShardBootstrap) ShouldSync added in v1.0.3

func (boot ShardBootstrap) ShouldSync() bool

ShouldSync method returns the sync state of the node. If it returns 'true', this means that the node is not synchronized yet and it has to continue the bootstrapping mechanism, otherwise the node is already synced and it can participate to the consensus, if it is in the jobDone group of this rounder. Note that when the node is not connected to the network, ShouldSync returns true but the SyncBlock is not automatically called

func (*ShardBootstrap) StartSync

func (boot *ShardBootstrap) StartSync()

StartSync method will start SyncBlocks as a go routine

func (ShardBootstrap) StopSync

func (boot ShardBootstrap) StopSync()

StopSync method will stop SyncBlocks

func (*ShardBootstrap) SyncBlock

func (boot *ShardBootstrap) SyncBlock() error

SyncBlock method actually does the synchronization. It requests the next block header from the pool and if it is not found there it will be requested from the network. After the header is received, it requests the block body in the same way(pool and than, if it is not found in the pool, from network). If either header and body are received the ProcessBlock and CommitBlock method will be called successively. These methods will execute the block and its transactions. Finally if everything works, the block will be committed in the blockchain, and all this mechanism will be reiterated for the next block.

type TestMetaBootstrap

type TestMetaBootstrap struct {
	*MetaBootstrap
}

TestMetaBootstrap extends MetaBootstrap and is used in integration tests as it exposes some funcs that are not supposed to be used in production code Exported funcs simplify the reproduction of edge cases

func (TestMetaBootstrap) AddSyncStateListener

func (boot TestMetaBootstrap) AddSyncStateListener(syncStateListener func(isSyncing bool))

AddSyncStateListener adds a syncStateListener that get notified each time the sync status of the node changes

func (*TestMetaBootstrap) RollBack

func (tmb *TestMetaBootstrap) RollBack(revertUsingForkNonce bool) error

RollBack decides to call (or not) the rollBackOneBlock on the current block from the blockchain structure

func (*TestMetaBootstrap) SetProbableHighestNonce

func (tmb *TestMetaBootstrap) SetProbableHighestNonce(nonce uint64)

SetProbableHighestNonce sets the probable highest nonce in the contained fork detector

func (TestMetaBootstrap) SetStatusHandler

func (boot TestMetaBootstrap) SetStatusHandler(handler core.AppStatusHandler) error

SetStatusHandler will set the instance of the AppStatusHandler

func (TestMetaBootstrap) ShouldSync added in v1.0.24

func (boot TestMetaBootstrap) ShouldSync() bool

ShouldSync method returns the sync state of the node. If it returns 'true', this means that the node is not synchronized yet and it has to continue the bootstrapping mechanism, otherwise the node is already synced and it can participate to the consensus, if it is in the jobDone group of this rounder. Note that when the node is not connected to the network, ShouldSync returns true but the SyncBlock is not automatically called

func (TestMetaBootstrap) StopSync

func (boot TestMetaBootstrap) StopSync()

StopSync method will stop SyncBlocks

type TestShardBootstrap

type TestShardBootstrap struct {
	*ShardBootstrap
}

TestShardBootstrap extends ShardBootstrap and is used in integration tests as it exposes some funcs that are not supposed to be used in production code Exported funcs simplify the reproduction of edge cases

func (TestShardBootstrap) AddSyncStateListener

func (boot TestShardBootstrap) AddSyncStateListener(syncStateListener func(isSyncing bool))

AddSyncStateListener adds a syncStateListener that get notified each time the sync status of the node changes

func (*TestShardBootstrap) RollBack

func (tsb *TestShardBootstrap) RollBack(revertUsingForkNonce bool) error

RollBack decides to call (or not) the rollBackOneBlock on the current block from the blockchain structure

func (*TestShardBootstrap) SetProbableHighestNonce

func (tsb *TestShardBootstrap) SetProbableHighestNonce(nonce uint64)

SetProbableHighestNonce sets the probable highest nonce in the contained fork detector

func (TestShardBootstrap) SetStatusHandler

func (boot TestShardBootstrap) SetStatusHandler(handler core.AppStatusHandler) error

SetStatusHandler will set the instance of the AppStatusHandler

func (TestShardBootstrap) ShouldSync added in v1.0.24

func (boot TestShardBootstrap) ShouldSync() bool

ShouldSync method returns the sync state of the node. If it returns 'true', this means that the node is not synchronized yet and it has to continue the bootstrapping mechanism, otherwise the node is already synced and it can participate to the consensus, if it is in the jobDone group of this rounder. Note that when the node is not connected to the network, ShouldSync returns true but the SyncBlock is not automatically called

func (TestShardBootstrap) StopSync

func (boot TestShardBootstrap) StopSync()

StopSync method will stop SyncBlocks

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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