peering

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 38 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 (
	TraceTagAutopeering = "autopeering"
)
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

func TestMultiAddrString

func TestMultiAddrString(peerID peer.ID, port int) 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
}

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

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 peer which has txStore Return number of peer pull request was sent to

func (*Peers) Run

func (ps *Peers) Run()

func (*Peers) SelfID

func (ps *Peers) SelfID() 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