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 HivePeerToPeerID(peer *peer.Peer) (peer2.ID, error)
- func MultiAddrFromPeeringService(peer *peer.Peer, serviceKey service.Key) (multiaddr.Multiaddr, error)
- func RegisterAutopeeringProtocolInMultiAddresses() error
- type LocalPeerContainer
- type LogF
- type Manager
- func (a *Manager) Discovery() *discover.Protocol
- func (a *Manager) Init(localPeerContainer *LocalPeerContainer, initSelection bool)
- func (a *Manager) LocalPeerContainer() *LocalPeerContainer
- func (a *Manager) P2PServiceKey() service.Key
- func (a *Manager) Run(ctx context.Context)
- func (a *Manager) Selection() *selection.Protocol
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 ¶
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 HivePeerToPeerID ¶
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 LocalPeerContainer ¶
type LocalPeerContainer struct {
// contains filtered or unexported fields
}
LocalPeerContainer defines the container for the local autopeering peer.
func NewLocalPeerContainer ¶
func (*LocalPeerContainer) Close ¶
func (l *LocalPeerContainer) Close() error
func (*LocalPeerContainer) Local ¶
func (l *LocalPeerContainer) Local() *peer.Local
Local returns the local hive.go peer from the container.
type Manager ¶
type Manager struct { // the logger used to log events. *logger.WrappedLogger // contains filtered or unexported fields }
func NewManager ¶
func (*Manager) Init ¶
func (a *Manager) Init(localPeerContainer *LocalPeerContainer, initSelection bool)
func (*Manager) LocalPeerContainer ¶
func (a *Manager) LocalPeerContainer() *LocalPeerContainer
LocalPeerContainer returns the container for the local autopeering peer and database.
func (*Manager) P2PServiceKey ¶
P2PServiceKey is the peering service key.