π’ unaiverse.networking.p2p.golibp2p
What this module does π’
Declares the GoLibP2P ctypes wrapper class that types the foreign-function interface to the compiled Go libp2p shared library.
golibp2p
¶
βββββ βββββ ββββββ βββββ βββββ βββββ βββββ ββββββββββ βββββββββββ βββββββββ ββββββββββ
βββββ βββββ ββββββββ βββββ βββββ βββββ βββββ ββββββββββββββββββββββββ ββββββββββββββββββββββ
ββββ ββββ ββββββββ ββββ ββββββ ββββ ββββ ββββ ββββ β β ββββ ββββ ββββ βββ ββββ β β
ββββ ββββ βββββββββββββ ββββββββ ββββ ββββ ββββ βββββββ βββββββββββ βββββββββββ βββββββ
ββββ ββββ ββββ ββββββββ βββββββ ββββ βββββ βββ βββββββ ββββββββββββ βββββββββββ βββββββ
ββββ ββββ ββββ βββββββ ββββββββ ββββ βββββββββ ββββ β β ββββ ββββ βββ ββββ ββββ β β
ββββββββββ βββββ βββββββββββββββββ βββββ βββββ ββββββββββ βββββ ββββββββββββββββ ββββββββββ
ββββββββ βββββ βββββ ββββββββ βββββ βββ ββββββββββ βββββ βββββ βββββββββ ββββββββββ
A Collectionless AI Project (https://collectionless.ai)
Registration/Login: https://unaiverse.io
Code Repositories: https://github.com/collectionlessai/
Main Developers: Stefano Melacci (Project Leader), Christian Di Maio, Tommaso Guidi
GoLibP2P
¶
Placeholder for the Go-based libp2p networking backend integration.
This class is reserved for future implementation of a networking layer built on top of
go-libp2p <https://github.com/libp2p/go-libp2p>_, the Go reference implementation of
the libp2p peer-to-peer networking stack. When implemented, it will expose a Python
interface to the Go runtime so that UNaIVERSE nodes can participate in the libp2p
overlay network without relying solely on the pure-Python p2p layer.
Note
This class currently contains no implementation. It is a forward declaration and should not be instantiated in production code.
InitializeLibrary
¶
InitializeLibrary(max_instances: int, max_num_channels: int, max_queue_per_channel: int, max_msg_size: int, log_config: bytes) -> None
InitializeLibrary(max_instances: int, max_queue_per_channel: int, max_num_channels: int, max_msg_size: int, enable_logging: int) -> bytes
Configures the P2P library.
Source code in unaiverse/networking/p2p/golibp2p.py
CreateNode
¶
CreateNode(instance: int, node_config_json: bytes) -> bytes
Creates a node in the P2P network and returns a JSON string with node information.
CloseNode
¶
CloseNode(instance: int) -> bytes
Closes the node and frees all resources.
Source code in unaiverse/networking/p2p/golibp2p.py
GetNodeAddresses
¶
GetConnectedPeers
¶
GetConnectedPeers(instance: int) -> bytes
Returns a JSON string listing connected peers.
GetRendezvousPeers
¶
GetRendezvousPeers(instance: int) -> bytes
Returns a JSON string listing rendezvous peers.
ConnectTo
¶
ConnectTo(instance: int, multiaddrs_json: bytes) -> bytes
Connects to a peer using the provided multiaddress. Returns a JSON string with the result.
DisconnectFrom
¶
DisconnectFrom(instance: int, peer_id: bytes) -> bytes
Disconnects from the given peer id. Returns a JSON result.
SendMessageToPeer
¶
SendMessageToPeer(instance: int, channel: bytes, data: bytes, data_len: int) -> bytes
MessageQueueLength
¶
MessageQueueLength(instance: int) -> int
Returns the current length of the message queue.
PopMessages
¶
PopNMessages(instance: int) -> bytes
Pops the first message in each channel queue and returns them as a list.
SubscribeToTopic
¶
SubscribeToTopic(instance: int, topic_composite_key: bytes) -> bytes
Subscribes to a topic and returns a JSON string with the result.
UnsubscribeFromTopic
¶
UnsubscribeFromTopic(instance: int, topic_composite_key: bytes) -> bytes
Unsubscribe from a topic and returns a JSON string with the result.
ReserveOnRelay
¶
ReserveOnRelay(instance: int, relay_peer_id: bytes) -> bytes
Reserves a relay port on the network. Returns a JSON result.
GetWebRTCConnections
¶
GetWebRTCConnections(instance: int) -> bytes
Returns a list of all active WebRTC connections. Returns a JSON result.
FreeString
¶
FreeString(arg: bytes) -> None
Frees a string previously allocated by the shared library.
FreeInt
¶
FreeInt(arg: int) -> None
Frees an integer previously allocated by the shared library.