netsync

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

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

func Fuzz added in v1.0.2

func Fuzz(data []byte) int

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) AddHash

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

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()

Jump to

Keyboard shortcuts

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