Documentation ¶
Index ¶
- Constants
- func Fuzz(data []byte) int
- type MessageConsumer
- type MessageIDEnum
- type PendingBlock
- type RequestManager
- type RequestState
- type SyncManager
- func (sm *SyncManager) EncodeMessage(message interface{}) (common.Bytes, error)
- func (sm *SyncManager) GetChannelIDs() []common.ChannelIDEnum
- func (sm *SyncManager) HandleMessage(msg p2ptypes.Message) (err error)
- func (sm *SyncManager) ParseMessage(peerID string, channelID common.ChannelIDEnum, rawMessageBytes common.Bytes) (p2ptypes.Message, error)
- func (sm *SyncManager) PassdownMessage(msg interface{})
- func (sm *SyncManager) Start(ctx context.Context)
- func (sm *SyncManager) Stop()
- func (sm *SyncManager) Wait()
Constants ¶
View Source
const ( RequestToSendDataReq = iota RequestWaitingDataResp )
View Source
const Expiration = 300 * time.Second
View Source
const MaxInventoryRequestInterval = 30 * time.Second
View Source
const MinInventoryRequestInterval = 3 * time.Second
View Source
const RequestQuotaPerSecond = 100
View Source
const RequestTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MessageConsumer ¶
type MessageConsumer interface {
AddMessage(interface{})
}
type MessageIDEnum ¶
type MessageIDEnum uint8
const ( MessageIDInvRequest MessageIDEnum = iota MessageIDInvResponse MessageIDDataRequest MessageIDDataResponse )
type PendingBlock ¶
type PendingBlock struct {
// contains filtered or unexported fields
}
func NewPendingBlock ¶
func NewPendingBlock(x common.Hash, peerIds []string) *PendingBlock
func (*PendingBlock) HasExpired ¶ added in v1.0.2
func (pb *PendingBlock) HasExpired() bool
func (*PendingBlock) HasTimedOut ¶
func (pb *PendingBlock) HasTimedOut() bool
func (*PendingBlock) UpdateTimestamp ¶
func (pb *PendingBlock) UpdateTimestamp()
type RequestManager ¶
type RequestManager struct {
// contains filtered or unexported fields
}
func NewRequestManager ¶
func NewRequestManager(syncMgr *SyncManager) *RequestManager
func (*RequestManager) AddBlock ¶
func (rm *RequestManager) AddBlock(block *core.Block)
func (*RequestManager) Start ¶
func (rm *RequestManager) Start(ctx context.Context)
func (*RequestManager) Stop ¶
func (rm *RequestManager) Stop()
func (*RequestManager) Wait ¶
func (rm *RequestManager) Wait()
type RequestState ¶
type RequestState uint8
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager is an intermediate layer between consensus engine and p2p network. Its main responsibilities are to manage fast blocks sync among peers and buffer orphaned block/CC. Otherwise messages are passed through to consensus engine.
func NewSyncManager ¶
func NewSyncManager(chain *blockchain.Chain, cons core.ConsensusEngine, network p2p.Network, disp *dispatcher.Dispatcher, consumer MessageConsumer) *SyncManager
func (*SyncManager) EncodeMessage ¶
func (sm *SyncManager) EncodeMessage(message interface{}) (common.Bytes, error)
EncodeMessage implements p2p.MessageHandler interface.
func (*SyncManager) GetChannelIDs ¶
func (sm *SyncManager) GetChannelIDs() []common.ChannelIDEnum
GetChannelIDs implements the p2p.MessageHandler interface.
func (*SyncManager) HandleMessage ¶
func (sm *SyncManager) HandleMessage(msg p2ptypes.Message) (err error)
HandleMessage implements p2p.MessageHandler interface.
func (*SyncManager) ParseMessage ¶
func (sm *SyncManager) ParseMessage(peerID string, channelID common.ChannelIDEnum, rawMessageBytes common.Bytes) (p2ptypes.Message, error)
ParseMessage implements p2p.MessageHandler interface.
func (*SyncManager) PassdownMessage ¶
func (sm *SyncManager) PassdownMessage(msg interface{})
PassdownMessage passes message through to the consumer.
func (*SyncManager) Start ¶
func (sm *SyncManager) Start(ctx context.Context)
func (*SyncManager) Stop ¶
func (sm *SyncManager) Stop()
func (*SyncManager) Wait ¶
func (sm *SyncManager) Wait()
Click to show internal directories.
Click to hide internal directories.