p2p

package
v0.0.0-...-d44451d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 38 Imported by: 18

Documentation

Index

Constants

View Source
const DefaultPort = 8999
View Source
const DevnetNetworkId = "/wormhole/dev"

The Devnet bootstrap peers are derived from the guardian key so we can't include them here.

View Source
const HighWaterMarkDefault = 400
View Source
const LowWaterMarkDefault = 100
View Source
const MainnetBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const MainnetCcqBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const MainnetNetworkId = "/wormhole/mainnet/2"

This is the definitive source for the default network parameters. Please reference these (or use the methods below), but avoid copying them!

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.

View Source
const TestnetBootstrapPeers = "" /* 328-byte string literal not displayed */
View Source
const TestnetCcqBootstrapPeers = "" /* 328-byte string literal not displayed */
View Source
const TestnetNetworkId = "/wormhole/testnet/2/1"

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 GetBootstrapPeers

func GetBootstrapPeers(env common.Environment) (string, error)

GetBootstrapPeers returns the default p2p bootstrap peers for mainnet and testnet. For any other environment, it returns an error.

func GetCcqBootstrapPeers

func GetCcqBootstrapPeers(env common.Environment) (string, error)

GetCcqBootstrapPeers returns the default ccq bootstrap peers for mainnet and testnet. For any other environment, it returns an error.

func GetNetworkId

func GetNetworkId(env common.Environment) string

GetNetworkId returns the default network ID.

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
	// GossipAdvertiseAddress is an override for the external IP advertised via p2p to other peers.
	GossipAdvertiseAddress string
}

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