Documentation ¶
Index ¶
- Constants
- func Fuzz(data []byte) int
- type Blocks
- type HeaderHeap
- type Headers
- type MessageConsumer
- type MessageIDEnum
- type PendingBlock
- type RequestManager
- func (rm *RequestManager) AddActivePeer(activePeerID string)
- func (rm *RequestManager) AddBlock(block *core.Block)
- func (rm *RequestManager) AddHash(x common.Hash, peerIDs []string, fromGossip bool)
- func (rm *RequestManager) AddHeader(header *core.BlockHeader, peerIDs []string)
- func (rm *RequestManager) IsGossipBlock(hash common.Hash) bool
- func (rm *RequestManager) Start(ctx context.Context)
- func (rm *RequestManager) Stop()
- func (rm *RequestManager) Wait()
- 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 RequestToSendBodyReq RequestWaitingBodyResp )
View Source
const Expiration = 300 * time.Second
View Source
const FastsyncRequestQuotaPerSecond = 50
View Source
const GossipRequestQuotaPerSecond = 50
View Source
const MaxBlocksPerRequest = 8
View Source
const MaxInventoryRequestInterval = 3 * time.Second
View Source
const MaxNumPeersToSendRequests = 4
View Source
const MinInventoryRequestInterval = 3 * time.Second
View Source
const RefreshCounterLimit = 4
View Source
const RequestTimeout = 5 * time.Second
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HeaderHeap ¶ added in v1.1.0
type HeaderHeap []*PendingBlock
func (HeaderHeap) Len ¶ added in v1.1.0
func (h HeaderHeap) Len() int
func (HeaderHeap) Less ¶ added in v1.1.0
func (h HeaderHeap) Less(i, j int) bool
func (*HeaderHeap) Pop ¶ added in v1.1.0
func (h *HeaderHeap) Pop() interface{}
func (*HeaderHeap) Push ¶ added in v1.1.0
func (h *HeaderHeap) Push(x interface{})
func (HeaderHeap) Swap ¶ added in v1.1.0
func (h HeaderHeap) Swap(i, j int)
type Headers ¶ added in v1.1.0
type Headers struct {
HeaderArray []*core.BlockHeader
}
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, fromGossip bool) *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) AddActivePeer ¶ added in v1.1.0
func (rm *RequestManager) AddActivePeer(activePeerID string)
func (*RequestManager) AddBlock ¶
func (rm *RequestManager) AddBlock(block *core.Block)
AddBlock process an incoming block. The block is NOT saved to disk yet.
func (*RequestManager) AddHash ¶
func (rm *RequestManager) AddHash(x common.Hash, peerIDs []string, fromGossip bool)
func (*RequestManager) AddHeader ¶ added in v1.1.0
func (rm *RequestManager) AddHeader(header *core.BlockHeader, peerIDs []string)
func (*RequestManager) IsGossipBlock ¶ added in v1.1.0
func (rm *RequestManager) IsGossipBlock(hash common.Hash) bool
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.