netsync

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestToSendDataReq = iota
	RequestWaitingDataResp
	RequestToSendBodyReq
	RequestWaitingBodyResp
)
View Source
const DumpBlockCacheLimit = 32
View Source
const Expiration = 300 * time.Second
View Source
const FastsyncRequestQuota = 8 // Max number of outstanding block requests
View Source
const GossipRequestQuotaPerSecond = 10
View Source
const MaxBlocksPerRequest = 4
View Source
const MaxInventoryRequestInterval = 6 * time.Second
View Source
const MaxNumPeersToSendRequests = 4
View Source
const MaxPeerActiveScore = 16
View Source
const MinInventoryRequestInterval = 6 * time.Second
View Source
const RefreshCounterLimit = 4
View Source
const RequestTimeout = 10 * time.Second

Variables

This section is empty.

Functions

func Fuzz

func Fuzz(data []byte) int

Types

type Blocks

type Blocks struct {
	BlockArray []*core.Block
}

type HeaderHeap

type HeaderHeap []*PendingBlock

func (HeaderHeap) Len

func (h HeaderHeap) Len() int

func (HeaderHeap) Less

func (h HeaderHeap) Less(i, j int) bool

func (*HeaderHeap) Pop

func (h *HeaderHeap) Pop() interface{}

func (*HeaderHeap) Push

func (h *HeaderHeap) Push(x interface{})

func (HeaderHeap) Swap

func (h HeaderHeap) Swap(i, j int)

type Headers

type Headers struct {
	HeaderArray []*core.BlockHeader
}

type MessageConsumer

type MessageConsumer interface {
	AddMessage(interface{})
}

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

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, reporter *rp.Reporter) *RequestManager

func (*RequestManager) AddActivePeer

func (rm *RequestManager) AddActivePeer(activePeerID string)

func (*RequestManager) AddBlock

func (rm *RequestManager) AddBlock(block *core.Block)

AddBlock process an incoming block.

func (*RequestManager) AddHash

func (rm *RequestManager) AddHash(x common.Hash, peerIDs []string, fromGossip bool)

func (*RequestManager) AddHeader

func (rm *RequestManager) AddHeader(header *core.BlockHeader, peerIDs []string)

func (*RequestManager) IsGossipBlock

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, networkOld p2p.Network, network p2pl.Network, disp *dispatcher.Dispatcher, consumer MessageConsumer, reporter *rp.Reporter) *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()

Jump to

Keyboard shortcuts

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