routes

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

This package provides the DPOS routes(network addresses) protocol, it can collect all DPOS peer addresses from the normal P2P network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type Config

type Config struct {
	// The PID of this peer if it is an arbiter.
	PID []byte

	// The network address of this arbiter.
	Addr string

	// TimeSource is the median time source of the P2P network.
	TimeSource blockchain.MedianTimeSource

	// Sign the addr message of this arbiter.
	Sign func(data []byte) (signature []byte)

	// IsCurrent returns whether BlockChain synced to best height.
	IsCurrent func() bool

	// RelayAddr relays the addresses inventory to the P2P network.
	RelayAddr func(iv *msg.InvVect, data interface{})

	// OnCipherAddr will be invoked when an address cipher received.
	OnCipherAddr func(pid dp.PID, addr []byte)
}

Config defines the parameters to create a Route instance.

type Routes

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

Routes is the DPOS routes implementation.

func New

func New(cfg *Config) *Routes

New creates and return a Routes instance.

func (*Routes) AnnounceAddr

func (r *Routes) AnnounceAddr()

AnnounceAddr schedules an local address announce to the P2P network, it used to re-announce the local address when DPoS network go bad.

func (*Routes) DonePeer

func (r *Routes) DonePeer(peer *peer.Peer)

DonePeer notifies the disconnected peer.

func (*Routes) NewPeer

func (r *Routes) NewPeer(peer *peer.Peer)

NewPeer notifies the new connected peer.

func (*Routes) OnGetData

func (r *Routes) OnGetData(p *peer.Peer, m *msg.GetData)

OnGetData handles the passed GetData message of the peer.

func (*Routes) QueueDAddr

func (r *Routes) QueueDAddr(p *peer.Peer, m *msg.DAddr)

QueueInv adds the passed DAddr message and peer to the addr handling queue.

func (*Routes) QueueInv

func (r *Routes) QueueInv(p *peer.Peer, m *msg.Inv)

QueueInv adds the passed Inv message and peer to the addr handling queue.

func (*Routes) Start

func (r *Routes) Start()

Start starts the Routes instance to sync DPOS addresses.

func (*Routes) Stop

func (r *Routes) Stop()

Stop quits the syncing address handler.

Jump to

Keyboard shortcuts

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