netsync

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnexpectedError = iota
	AlreadyStartError
	AlreadyShutdownError
)

Variables

View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	Message string
}{
	UnexpectedError:      {-1, "Unexpected error"},
	AlreadyStartError:    {-2, "Already started"},
	AlreadyShutdownError: {-3, "We're shutting down"},
}
View Source
var Logger = NetSyncLogger{}

Global instant to use

Functions

This section is empty.

Types

type NetSync

type NetSync struct {
	// contains filtered or unexported fields
}

NetSync is a gate for message to enter node from network (after Peerconn), all message must be process by NetSync before proccessed by other package in node NetSync parses message from other peer, identifies type of message After parsing, it will detect if message is duplicate or not If message is duplicate then discard it, otherwise pass it to the right handler NetSync start when node start and run all the time while node is alive and it will stop when received quit signal

func (*NetSync) GetCPUUsage

func (netSync *NetSync) GetCPUUsage()

func (*NetSync) Init

func (netSync *NetSync) Init(cfg *NetSyncConfig)

func (*NetSync) QueueBlock

func (netSync *NetSync) QueueBlock(_ *peer.Peer, msg wire.Message, done chan struct{})

QueueBlock adds the passed block message and peer to the block handling queue. Responds to the done channel argument after the block message is processed.

func (*NetSync) QueueGetBlockBeacon

func (netSync *NetSync) QueueGetBlockBeacon(peer *peer.Peer, msg *wire.MessageGetBlockBeacon, done chan struct{})

func (*NetSync) QueueGetBlockShard

func (netSync *NetSync) QueueGetBlockShard(peer *peer.Peer, msg *wire.MessageGetBlockShard, done chan struct{})

func (*NetSync) QueueMessage

func (netSync *NetSync) QueueMessage(peer *peer.Peer, msg wire.Message, done chan struct{})

func (*NetSync) QueueTx

func (netSync *NetSync) QueueTx(peer *peer.Peer, msg *wire.MessageTx, done chan struct{}) error

func (*NetSync) QueueTxPrivacyToken

func (netSync *NetSync) QueueTxPrivacyToken(peer *peer.Peer, msg *wire.MessageTxPrivacyToken, done chan struct{}) error

func (*NetSync) Start

func (netSync *NetSync) Start() error

func (*NetSync) Stop

func (netSync *NetSync) Stop()

Stop gracefully shuts down the sync manager by stopping all asynchronous handlers and waiting for them to finish.

type NetSyncCache

type NetSyncCache struct {
	// contains filtered or unexported fields
}

type NetSyncConfig

type NetSyncConfig struct {
	Syncker          *syncker.SynckerManager
	BlockChain       *blockchain.BlockChain
	TxMemPool        *mempool.TxPool
	PubSubManager    *pubsub.PubSubManager
	TransactionEvent pubsub.EventChannel // transaction event
	// RoleInCommitteesEvent pubsub.EventChannel // role in committees event
	BeaconBlockEvent pubsub.EventChannel // beacon block event
	ShardBlockEvent  pubsub.EventChannel // shard block event
	RelayShard       []byte
	// RoleInCommittees      int
	// roleInCommitteesMtx   sync.RWMutex
	Server interface {
		// list functions callback which are assigned from Server struct
		PushMessageToPeer(wire.Message, libp2p.ID) error
		PushMessageToAll(wire.Message) error
		PushMessageToShard(msg wire.Message, shard byte) error
	}
	Consensus interface {
		OnBFTMsg(*wire.MessageBFT)
	}
}

type NetSyncError

type NetSyncError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func NewNetSyncError

func NewNetSyncError(key int, err error, params ...interface{}) *NetSyncError

func (NetSyncError) Error

func (e NetSyncError) Error() string

type NetSyncLogger

type NetSyncLogger struct {
	// contains filtered or unexported fields
}

func (*NetSyncLogger) Init

func (netSyncLogger *NetSyncLogger) Init(inst common.Logger)

Jump to

Keyboard shortcuts

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