p2p

package
v0.0.0-...-43fc98a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPort = 8999
View Source
const HighWaterMarkDefault = 400
View Source
const LowWaterMarkDefault = 100
View Source
const P2P_SUBSCRIPTION_BUFFER_SIZE = 1024
View Source
const P2P_VALIDATE_QUEUE_SIZE = 1024
View Source
const TESTNET_BOOTSTRAP_DHI = 350

TESTNET_BOOTSTRAP_DHI configures how many nodes may connect to the testnet bootstrap node. This number should not exceed HighWaterMark.

Variables

View Source
var (
	DefaultRegistry = NewRegistry()
)

Functions

func BootstrapAddrs

func BootstrapAddrs(logger *zap.Logger, bootstrapPeers string, self peer.ID) (bootstrappers []peer.AddrInfo, isBootstrapNode bool)

BootstrapAddrs takes a comma-separated string of multi-address strings and returns an array of []peer.AddrInfo that does not include `self`. if `self` is part of `bootstrapPeers`, return isBootstrapNode=true

func ConnectToPeers

func ConnectToPeers(ctx context.Context, logger *zap.Logger, h host.Host, peers []peer.AddrInfo) (successes int)

ConnectToPeers connects `h` to `peers` and returns the number of successful connections.

func DefaultConnectionManager

func DefaultConnectionManager() (*connmgr.BasicConnMgr, error)

func NewHost

func NewHost(logger *zap.Logger, ctx context.Context, networkID string, bootstrapPeers string, components *Components, priv crypto.PrivKey) (host.Host, error)

func NewRegistry

func NewRegistry() *registry

func Run

func Run(
	obsvC chan<- *common.MsgWithTimeStamp[gossipv1.SignedObservation],
	obsvReqC chan<- *gossipv1.ObservationRequest,
	obsvReqSendC <-chan *gossipv1.ObservationRequest,
	gossipSendC chan []byte,
	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
	priv crypto.PrivKey,
	gk *ecdsa.PrivateKey,
	gst *common.GuardianSetState,
	networkID string,
	bootstrapPeers string,
	nodeName string,
	disableHeartbeatVerify bool,
	rootCtxCancel context.CancelFunc,
	acct *accountant.Accountant,
	gov *governor.ChainGovernor,
	signedGovCfg chan *gossipv1.SignedChainGovernorConfig,
	signedGovSt chan *gossipv1.SignedChainGovernorStatus,
	components *Components,
	ibcFeaturesFunc func() string,
	gatewayRelayerEnabled bool,
	ccqEnabled bool,
	signedQueryReqC chan<- *gossipv1.SignedQueryRequest,
	queryResponseReadC <-chan *query.QueryResponsePublication,
	ccqBootstrapPeers string,
	ccqPort uint,
	ccqAllowedPeers string,
) func(ctx context.Context) error

Types

type Components

type Components struct {
	// P2PIDInHeartbeat determines if the guardian will put it's libp2p node ID in the authenticated heartbeat payload
	P2PIDInHeartbeat           bool
	ListeningAddressesPatterns []string
	// Port on which the Guardian is going to bind
	Port uint
	// ConnMgr is the ConnectionManager that the Guardian is going to use
	ConnMgr *connmgr.BasicConnMgr
	// ProtectedHostByGuardianKey is used to ensure that only one p2p peer can be protected by any given known guardian key
	ProtectedHostByGuardianKey map[eth_common.Address]peer.ID
	// ProtectedHostByGuardianKeyLock is only useful to prevent a race condition in test as ProtectedHostByGuardianKey
	// is only accessed by a single routine at any given time in a running Guardian.
	ProtectedHostByGuardianKeyLock sync.Mutex
	// WarnChannelOverflow: If true, errors due to overflowing channels will produce logger.Warn
	WarnChannelOverflow bool
	// SignedHeartbeatLogLevel is the log level at which SignedHeartbeatReceived events will be logged.
	SignedHeartbeatLogLevel zapcore.Level
	// GossipParams is used to configure the GossipSub instance used by the Guardian.
	GossipParams pubsub.GossipSubParams
}

func DefaultComponents

func DefaultComponents() *Components

func (*Components) ListeningAddresses

func (f *Components) ListeningAddresses() []string

Jump to

Keyboard shortcuts

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