peering

package
v0.1.3-testnet Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceTagHeartBeatRecv = "peering_hb_recv"
	TraceTagHeartBeatSend = "peering_hb_send"
)
View Source
const (
	Name     = "peers"
	TraceTag = Name
)
View Source
const BeginPort = 4000
View Source
const (
	MaxPayloadSize = math.MaxUint16 - 4
)

MaxPayloadSize caps the message size. It includes 4 bytes of the size

View Source
const PullTransactions = byte(iota)
View Source
const TestBlacklistTTL = 20 // ms
View Source
const (
	TraceTagAutopeering = "autopeering"
)
View Source
const (
	TraceTagPeeringPeers = "peering_peers"
)
View Source
const TraceTagPullTargets = "peering_pull_targets"

Variables

This section is empty.

Functions

func MultiAddrString

func MultiAddrString(i int, port int) string

func ShortPeerIDString

func ShortPeerIDString(id peer.ID) string

Types

type AddressFilter

type AddressFilter = func([]multiaddr.Multiaddr) []multiaddr.Multiaddr

func FilterAddresses

func FilterAddresses(allowLocalNetworks bool) AddressFilter

type Config

type Config struct {
	HostIDPrivateKey   ed25519.PrivateKey
	HostID             peer.ID
	HostPort           int
	PreConfiguredPeers map[string]_multiaddr // name -> PeerAddr. Static peers used also for bootstrap
	// MaxDynamicPeers if MaxDynamicPeers <= len(PreConfiguredPeers), autopeering is disabled, otherwise up to
	// MaxDynamicPeers - len(PreConfiguredPeers) will be auto-peered
	MaxDynamicPeers int
	// Node info
	IgnoreAllPullRequests                 bool
	AcceptPullRequestsFromStaticPeersOnly bool
	// AllowLocalIPs defines if local IPs are allowed to be used for autopeering.
	AllowLocalIPs bool `default:"false" usage:"allow local IPs to be used for autopeering"`
	// used for testing only. Otherwise, remote peer sets the pull flags
	ForcePullFromAllPeers bool
	// timeout for heartbeat. If not set, used special defaultSendHeartbeatTimeout
	SendTimeoutHeartbeat time.Duration

	// wait time to allow a blacklisted peer to connect again
	BlacklistTTL int
	// wait time after a disconnected peer can be reconnected again
	CooloffListTTL int

	// disable Quicreuse
	DisableQuicreuse bool
}

func MakeConfigFor

func MakeConfigFor(n, hostIdx int) *Config

type ExternalMultiAddresses

type ExternalMultiAddresses []string

type Peer

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

type Peers

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

func New

func New(env environment, cfg *Config) (*Peers, error)

func NewPeersDummy

func NewPeersDummy() *Peers

func NewPeersFromConfig

func NewPeersFromConfig(env environment) (*Peers, error)

func (*Peers) DurationSinceLastMessageFromPeer

func (ps *Peers) DurationSinceLastMessageFromPeer() time.Duration

func (*Peers) GetPeersInfo

func (ps *Peers) GetPeersInfo() *api.PeersInfo

func (*Peers) GossipTxBytesToPeers

func (ps *Peers) GossipTxBytesToPeers(txBytes []byte, metadata *txmetadata.TransactionMetadata, except ...peer.ID)

func (*Peers) Host

func (ps *Peers) Host() host.Host

func (*Peers) IsAlive

func (ps *Peers) IsAlive(id peer.ID) (isAlive bool)

func (*Peers) IsBlacklisted

func (ps *Peers) IsBlacklisted(id peer.ID) (isBlacklisted bool)

func (*Peers) NewStream

func (ps *Peers) NewStream(peerID peer.ID, pID protocol.ID, timeout time.Duration) (network.Stream, error)

func (*Peers) NumAlive

func (ps *Peers) NumAlive() (aliveStatic, aliveDynamic, pullTargets int)

func (*Peers) OnReceivePullTxRequest

func (ps *Peers) OnReceivePullTxRequest(fun func(from peer.ID, txid ledger.TransactionID))

func (*Peers) OnReceiveTxBytes

func (ps *Peers) OnReceiveTxBytes(fun func(from peer.ID, txBytes []byte, metadata *txmetadata.TransactionMetadata, txData []byte))

func (*Peers) PeerName

func (ps *Peers) PeerName(id peer.ID) string

func (*Peers) PullTransactionsFromNPeers

func (ps *Peers) PullTransactionsFromNPeers(nPeers int, txid ledger.TransactionID) int

PullTransactionsFromNPeers sends pull request to the random peers which has txStore Return number of peer pull request was sent to

func (*Peers) Run

func (ps *Peers) Run()

func (*Peers) SelfPeerID

func (ps *Peers) SelfPeerID() peer.ID

func (*Peers) SendTxBytesWithMetadataToPeer

func (ps *Peers) SendTxBytesWithMetadataToPeer(id peer.ID, txBytes []byte, metadata *txmetadata.TransactionMetadata) bool

func (*Peers) Stop

func (ps *Peers) Stop()

Jump to

Keyboard shortcuts

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