Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertHivePubKeyToPeerID(hivePubKey ed25519.PublicKey) (peer2.ID, error)
- func ConvertHivePubKeyToPeerIDOrLog(hivePubKey ed25519.PublicKey, log LogF) *peer2.ID
- func ConvertLibP2PPrivateKeyToHive(key *crypto.Ed25519PrivateKey) (*ed25519.PrivateKey, error)
- func ConvertPeerIDToHiveIdentity(peer *p2p.Peer) (*identity.Identity, error)
- func ConvertPeerIDToHiveIdentityOrLog(peer *p2p.Peer, log LogF) *identity.Identity
- func ExtractHostAndPortFromMultiAddr(multiAddr multiaddr.Multiaddr, portProtoCode int) (string, int, error)
- func ExtractPubKeyFromMultiAddr(multiAddr multiaddr.Multiaddr) (*ed25519.PublicKey, error)
- func GetEntryNodeMultiAddress(local *peer.Local) (multiaddr.Multiaddr, error)
- func HivePeerToAddrInfo(peer *peer.Peer, serviceKey service.Key) (*peer2.AddrInfo, error)
- func MultiAddrFromPeeringService(peer *peer.Peer, serviceKey service.Key) (multiaddr.Multiaddr, error)
- func RegisterAutopeeringProtocolInMultiAddresses() error
- type LocalPeerContainer
- type LogF
Constants ¶
const (
// ProtocolCode is the protocol code for autopeering within a multi address.
ProtocolCode = 1337
)
Variables ¶
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 ¶
ConvertHivePubKeyToPeerID converts a hive ed25519 public key from the hive package to a libp2p peer ID.
func ConvertHivePubKeyToPeerIDOrLog ¶
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 ¶
ConvertPeerIDToHiveIdentity converts a libp2p peer ID to a hive identity.
func ConvertPeerIDToHiveIdentityOrLog ¶
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 ¶
ExtractPubKeyFromMultiAddr extracts an ed25519 public key from the autopeering protocol portion of a multi address.
func GetEntryNodeMultiAddress ¶ added in v1.0.5
GetEntryNodeMultiAddress returns the multiaddress for the autopeering entry node.
func HivePeerToAddrInfo ¶
HivePeerToAddrInfo converts data from a hive autopeering peer to an AddrInfo containing a MultiAddr to the peer's peering port.
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 LocalPeerContainer ¶ added in v1.0.5
type LocalPeerContainer struct {
// contains filtered or unexported fields
}
LocalPeerContainer defines the container for the local autopeering peer.
func NewLocalPeerContainer ¶ added in v1.0.5
func (*LocalPeerContainer) Close ¶ added in v1.0.5
func (l *LocalPeerContainer) Close() error
func (*LocalPeerContainer) Local ¶ added in v1.0.5
func (lpc *LocalPeerContainer) Local() *peer.Local
Local returns the local hive.go peer from the container.