sync

package
v0.0.0-...-bda353b Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(parent, other queue.Item) int

Compare sort the items put into the queue in ascending order in routine, smaller level will be processed first

func NewBlockChainSyncServer

func NewBlockChainSyncServer(
	chainId string,
	net protocol.NetService,
	msgBus msgbus.MessageBus,
	blockchainStore protocol.BlockchainStore,
	ledgerCache protocol.LedgerCache,
	blockVerifier protocol.BlockVerifier,
	blockCommitter protocol.BlockCommitter,
	log protocol.Logger) protocol.SyncService

NewBlockChainSyncServer Create a new BlockChainSyncServer instance

Types

type BlockChainSyncServer

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

BlockChainSyncServer Service for synchronizing blocks

func (*BlockChainSyncServer) ListenSyncToIdealHeight

func (sync *BlockChainSyncServer) ListenSyncToIdealHeight() <-chan struct{}

ListenSyncToIdealHeight listen local block height has synced to ideal height

func (*BlockChainSyncServer) OnMessage

func (sync *BlockChainSyncServer) OnMessage(message *msgbus.Message)

OnMessage msgbus Subscriber interface implementation used to receive block notifications from msgbus, if the height of the newly received block is divisible by 3, then broadcast own block height to other peers

func (*BlockChainSyncServer) OnQuit

func (sync *BlockChainSyncServer) OnQuit()

OnQuit msgbus Subscriber interface implementation

func (*BlockChainSyncServer) Start

func (sync *BlockChainSyncServer) Start() error

Start BlockChainSyncServer preparing the required dependencies for the server to run properly if an error is encountered, the startup failed, please check it.

func (*BlockChainSyncServer) StartBlockSync

func (sync *BlockChainSyncServer) StartBlockSync()

StartBlockSync make sync service resume sending sync block requests to other peer nodes

func (*BlockChainSyncServer) Stop

func (sync *BlockChainSyncServer) Stop()

Stop stop sync service all work

func (*BlockChainSyncServer) StopBlockSync

func (sync *BlockChainSyncServer) StopBlockSync()

StopBlockSync make sync service stop sending sync block requests to other peer nodes

type BlockSyncServerConf

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

BlockSyncServerConf sync service configurable options

func NewBlockSyncServerConf

func NewBlockSyncServerConf() *BlockSyncServerConf

NewBlockSyncServerConf create a new BlockSyncServerConf instance with default values

func (*BlockSyncServerConf) SetBatchSizeFromOneNode

func (c *BlockSyncServerConf) SetBatchSizeFromOneNode(n uint64) *BlockSyncServerConf

SetBatchSizeFromOneNode set the number of blocks that can be fetched in one request

func (*BlockSyncServerConf) SetBlockPoolSize

func (c *BlockSyncServerConf) SetBlockPoolSize(n uint64) *BlockSyncServerConf

SetBlockPoolSize set block pool size this value will affect maximum number of cache blocks sync server has received and waiting to be processed

func (*BlockSyncServerConf) SetBlockRequestTime

func (c *BlockSyncServerConf) SetBlockRequestTime(n float64) *BlockSyncServerConf

SetBlockRequestTime set expiration time of the received request node will ignore the request sent multiple times by others for the same block within this time

func (*BlockSyncServerConf) SetDataDetectionTicker

func (c *BlockSyncServerConf) SetDataDetectionTicker(n float64) *BlockSyncServerConf

SetDataDetectionTicker set time interval for checking data in processor

func (*BlockSyncServerConf) SetLivenessTicker

func (c *BlockSyncServerConf) SetLivenessTicker(n float64) *BlockSyncServerConf

SetLivenessTicker set time interval for doing a liveness check

func (*BlockSyncServerConf) SetMinLagThreshold

func (c *BlockSyncServerConf) SetMinLagThreshold(n uint64) *BlockSyncServerConf

SetMinLagThreshold set the the minimum value local block height lags behind maximum block height If this value is reached, notify anyone who cares about this event

func (*BlockSyncServerConf) SetMinLagThresholdTime

func (c *BlockSyncServerConf) SetMinLagThresholdTime(n float64) *BlockSyncServerConf

SetMinLagThresholdTime set time threshold of minimum lags

func (*BlockSyncServerConf) SetNodeStatusTicker

func (c *BlockSyncServerConf) SetNodeStatusTicker(n float64) *BlockSyncServerConf

SetNodeStatusTicker set time interval for broadcasting to get other peers status

func (*BlockSyncServerConf) SetProcessBlockTicker

func (c *BlockSyncServerConf) SetProcessBlockTicker(n float64) *BlockSyncServerConf

SetProcessBlockTicker set time interval for processing blocks

func (*BlockSyncServerConf) SetReqTimeThreshold

func (c *BlockSyncServerConf) SetReqTimeThreshold(n float64) *BlockSyncServerConf

SetReqTimeThreshold set request time limit if the difference between own block height and the highest block height is 1 the time difference between two requests must be greater than reqTimeThreshold

func (*BlockSyncServerConf) SetSchedulerTicker

func (c *BlockSyncServerConf) SetSchedulerTicker(n float64) *BlockSyncServerConf

SetSchedulerTicker set time interval for scheduling block request

func (*BlockSyncServerConf) SetWaitTimeOfBlockRequestMsg

func (c *BlockSyncServerConf) SetWaitTimeOfBlockRequestMsg(n int64) *BlockSyncServerConf

SetWaitTimeOfBlockRequestMsg set sync block request timeout

type DataDetection

type DataDetection struct{}

DataDetection notify to do a data check

func (*DataDetection) Compare

func (m *DataDetection) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*DataDetection) Level

func (m *DataDetection) Level() int

Level get priority level

type LivenessMsg

type LivenessMsg struct{}

LivenessMsg to check whether the response of synchronous block request is timed out if received this message

func (*LivenessMsg) Compare

func (m *LivenessMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*LivenessMsg) Level

func (m *LivenessMsg) Level() int

Level get priority level

type NodeStatusMsg

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

NodeStatusMsg indicates that received status information from other nodes

func (*NodeStatusMsg) Compare

func (m *NodeStatusMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*NodeStatusMsg) Level

func (m *NodeStatusMsg) Level() int

Level get priority level

type Priority

type Priority interface {
	Level() int
}

Priority can return the priority level of one implementation

type ProcessBlockMsg

type ProcessBlockMsg struct{}

ProcessBlockMsg notify processor to do a block processing operation

func (*ProcessBlockMsg) Compare

func (m *ProcessBlockMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*ProcessBlockMsg) Level

func (m *ProcessBlockMsg) Level() int

Level get priority level

type ProcessedBlockResp

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

ProcessedBlockResp the result of the block being processed by the processor

func (*ProcessedBlockResp) Compare

func (m *ProcessedBlockResp) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*ProcessedBlockResp) Level

func (m *ProcessedBlockResp) Level() int

Level get priority level

type ReceivedBlockInfos

type ReceivedBlockInfos struct {
	*syncPb.SyncBlockBatch
	// contains filtered or unexported fields
}

ReceivedBlockInfos notify processor that it has received some blocks that needs to be processed

func (*ReceivedBlockInfos) Compare

func (m *ReceivedBlockInfos) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*ReceivedBlockInfos) Level

func (m *ReceivedBlockInfos) Level() int

Level get priority level

type Routine

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

Routine Provide hosting of the service in goroutine

func NewRoutine

func NewRoutine(name string, handle handleFunc, queryState getServiceState, log protocol.Logger) *Routine

NewRoutine create a Routine instance

type SchedulerMsg

type SchedulerMsg struct{}

SchedulerMsg notify scheduler to send a synchronous block request

func (*SchedulerMsg) Compare

func (m *SchedulerMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*SchedulerMsg) Level

func (m *SchedulerMsg) Level() int

Level get priority level

type StartSyncMsg

type StartSyncMsg struct {
}

StartSyncMsg notify sync server to resume to block data from other nodes

func (*StartSyncMsg) Compare

func (m *StartSyncMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*StartSyncMsg) Level

func (m *StartSyncMsg) Level() int

Level get priority level

type StopSyncMsg

type StopSyncMsg struct {
}

StopSyncMsg notify sync server to stop syncing block data from other nodes

func (*StopSyncMsg) Compare

func (m *StopSyncMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*StopSyncMsg) Level

func (m *StopSyncMsg) Level() int

Level get priority level

type SyncedBlockMsg

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

SyncedBlockMsg indicates that a synchronized block response was received

func (*SyncedBlockMsg) Compare

func (m *SyncedBlockMsg) Compare(other queue.Item) int

Compare invoke by queue.PriorityQueue to sort queue.Item

func (*SyncedBlockMsg) Level

func (m *SyncedBlockMsg) Level() int

Level get SyncedBlockMsg priority level

Jump to

Keyboard shortcuts

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