autopeering

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ProtocolCode is the protocol code for autopeering within a multi address.
	ProtocolCode = 1337
)

Variables

View Source
var (
	// ErrInvalidMultiAddrPubKeyAutopeering gets returned when a public key in a multi address autopeering protocol path is invalid.
	ErrInvalidMultiAddrPubKeyAutopeering = errors.New("invalid multi address autopeering public key")
	// ErrMultiAddrNoHost gets returned if a multi address does not contain any host, meaning it neither has a /ip4, /ip6 or /dns portion.
	ErrMultiAddrNoHost = errors.New("multi address contains no host")
)

Functions

func ConvertHivePubKeyToPeerID

func ConvertHivePubKeyToPeerID(hivePubKey ed25519.PublicKey) (peer2.ID, error)

ConvertHivePubKeyToPeerID converts a hive ed25519 public key from the hive package to a libp2p peer ID.

func ConvertHivePubKeyToPeerIDOrLog

func ConvertHivePubKeyToPeerIDOrLog(hivePubKey ed25519.PublicKey, log LogF) *peer2.ID

ConvertHivePubKeyToPeerIDOrLog converts a hive ed25519 public key from the hive package to a libp2p peer ID. if it fails it logs a warning with the error instead.

func ConvertLibP2PPrivateKeyToHive

func ConvertLibP2PPrivateKeyToHive(key *crypto.Ed25519PrivateKey) (*ed25519.PrivateKey, error)

ConvertLibP2PPrivateKeyToHive converts a libp2p private key to a hive private key.

func ConvertPeerIDToHiveIdentity

func ConvertPeerIDToHiveIdentity(peer *p2p.Peer) (*identity.Identity, error)

ConvertPeerIDToHiveIdentity converts a libp2p peer ID to a hive identity.

func ConvertPeerIDToHiveIdentityOrLog

func ConvertPeerIDToHiveIdentityOrLog(peer *p2p.Peer, log LogF) *identity.Identity

ConvertPeerIDToHiveIdentityOrLog converts a libp2p peer ID to a hive identity. if it fails it logs a warning with the error instead.

func ExtractHostAndPortFromMultiAddr

func ExtractHostAndPortFromMultiAddr(multiAddr multiaddr.Multiaddr, portProtoCode int) (string, int, error)

ExtractHostAndPortFromMultiAddr extracts the host and port from a multi address.

func ExtractPubKeyFromMultiAddr

func ExtractPubKeyFromMultiAddr(multiAddr multiaddr.Multiaddr) (*ed25519.PublicKey, error)

ExtractPubKeyFromMultiAddr extracts an ed25519 public key from the autopeering protocol portion of a multi address.

func GetEntryNodeMultiAddress

func GetEntryNodeMultiAddress(local *peer.Local) (multiaddr.Multiaddr, error)

GetEntryNodeMultiAddress returns the multiaddress for the autopeering entry node.

func HivePeerToAddrInfo

func HivePeerToAddrInfo(peer *peer.Peer, serviceKey service.Key) (*peer2.AddrInfo, error)

HivePeerToAddrInfo converts data from a hive autopeering peer to an AddrInfo containing a MultiAddr to the peer's peering port.

func HivePeerToPeerID

func HivePeerToPeerID(peer *peer.Peer) (peer2.ID, error)

HivePeerToPeerID converts data from a hive autopeering peer to a libp2p peer ID.

func MultiAddrFromPeeringService

func MultiAddrFromPeeringService(peer *peer.Peer, serviceKey service.Key) (multiaddr.Multiaddr, error)

MultiAddrFromPeeringService extracts a multi address from a hive peer's service.

func RegisterAutopeeringProtocolInMultiAddresses

func RegisterAutopeeringProtocolInMultiAddresses() error

RegisterAutopeeringProtocolInMultiAddresses registers the autopeering protocol for multi addresses. The 'autopeering' protocol value is the base58 encoded ed25519 public key and must be always 44 in length.

Types

type AutopeeringManager

type AutopeeringManager struct {
	// the logger used to log events.
	*utils.WrappedLogger
	// contains filtered or unexported fields
}

func NewAutopeeringManager

func NewAutopeeringManager(log *logger.Logger, bindAddress string, entryNodes []string, preferIPv6 bool, p2pServiceKey service.Key) *AutopeeringManager

func (*AutopeeringManager) Discovery

func (a *AutopeeringManager) Discovery() *discover.Protocol

Discovery returns the peer discovery protocol.

func (*AutopeeringManager) Init

func (a *AutopeeringManager) Init(localPeerContainer *LocalPeerContainer, initSelection bool)

func (*AutopeeringManager) LocalPeerContainer

func (a *AutopeeringManager) LocalPeerContainer() *LocalPeerContainer

LocalPeerContainer returns the container for the local autopeering peer and database.

func (*AutopeeringManager) P2PServiceKey

func (a *AutopeeringManager) P2PServiceKey() service.Key

P2PServiceKey is the peering service key.

func (*AutopeeringManager) Run

func (a *AutopeeringManager) Run(ctx context.Context)

func (*AutopeeringManager) Selection

func (a *AutopeeringManager) Selection() *selection.Protocol

Selection returns the peer selection protocol.

type LocalPeerContainer

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

LocalPeerContainer defines the container for the local autopeering peer.

func NewLocalPeerContainer

func NewLocalPeerContainer(p2pServiceKey service.Key,
	seed []byte,
	p2pDatabasePath string,
	dbEngine database.Engine,
	p2pBindMultiAddresses []string,
	autopeeringBindAddr string,
	runAsEntryNode bool) (*LocalPeerContainer, error)

func (*LocalPeerContainer) Close

func (l *LocalPeerContainer) Close() error

func (*LocalPeerContainer) Local

func (lpc *LocalPeerContainer) Local() *peer.Local

Local returns the local hive.go peer from the container.

type LogF

type LogF func(template string, args ...interface{})

Jump to

Keyboard shortcuts

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