Documentation ¶
Index ¶
- func Compare(parent, other queue.Item) int
- func NewBlockChainSyncServer(chainId string, net protocol.NetService, msgBus msgbus.MessageBus, ...) protocol.SyncService
- type BlockChainSyncServer
- func (sync *BlockChainSyncServer) ListenSyncToIdealHeight() <-chan struct{}
- func (sync *BlockChainSyncServer) OnMessage(message *msgbus.Message)
- func (sync *BlockChainSyncServer) OnQuit()
- func (sync *BlockChainSyncServer) Start() error
- func (sync *BlockChainSyncServer) StartBlockSync()
- func (sync *BlockChainSyncServer) Stop()
- func (sync *BlockChainSyncServer) StopBlockSync()
- type BlockSyncServerConf
- func (c *BlockSyncServerConf) SetBatchSizeFromOneNode(n uint64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetBlockPoolSize(n uint64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetBlockRequestTime(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetDataDetectionTicker(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetLivenessTicker(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetMinLagThreshold(n uint64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetMinLagThresholdTime(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetNodeStatusTicker(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetProcessBlockTicker(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetReqTimeThreshold(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetSchedulerTicker(n float64) *BlockSyncServerConf
- func (c *BlockSyncServerConf) SetWaitTimeOfBlockRequestMsg(n int64) *BlockSyncServerConf
- type DataDetection
- type LivenessMsg
- type NodeStatusMsg
- type Priority
- type ProcessBlockMsg
- type ProcessedBlockResp
- type ReceivedBlockInfos
- type Routine
- type SchedulerMsg
- type StartSyncMsg
- type StopSyncMsg
- type SyncedBlockMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
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
type LivenessMsg ¶
type LivenessMsg struct{}
LivenessMsg to check whether the response of synchronous block request is timed out if received this message
type NodeStatusMsg ¶
type NodeStatusMsg struct {
// contains filtered or unexported fields
}
NodeStatusMsg indicates that received status information from other nodes
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
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
type SchedulerMsg ¶
type SchedulerMsg struct{}
SchedulerMsg notify scheduler to send a synchronous block request
type StartSyncMsg ¶
type StartSyncMsg struct { }
StartSyncMsg notify sync server to resume to block data from other nodes
type StopSyncMsg ¶
type StopSyncMsg struct { }
StopSyncMsg notify sync server to stop syncing block data from other nodes
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