Documentation
¶
Index ¶
- Constants
- func GetConnectedPeers() []string
- func GetNodePeerID() string
- func MonitorNetwork(h host.Host)
- func RegisterNode(h host.Host, config *setup.Config) error
- func SendMessage(peerID string, msg string) error
- func SetGlobalAutoDiscoveryService(ads *AutoDiscoveryService)
- type AutoDiscoveryService
- type Notifee
Constants ¶
const ChatProtocolID = "/desvault/chat/1.0.0"
Variables ¶
This section is empty.
Functions ¶
func GetConnectedPeers ¶
func GetConnectedPeers() []string
GetConnectedPeers returns a slice of connected peer IDs.
func MonitorNetwork ¶
MonitorNetwork continuously monitors network connectivity and logs the current number of connected peers.
func RegisterNode ¶
RegisterNode registers the node on the network using the provided production configuration. This implementation performs an HTTP POST to a registration service endpoint. The endpoint is defined here as a default constant, but you can modify this to read from configuration.
func SendMessage ¶
SendMessage sends a chat message to the specified peer.
func SetGlobalAutoDiscoveryService ¶
func SetGlobalAutoDiscoveryService(ads *AutoDiscoveryService)
SetGlobalAutoDiscoveryService stores the global AutoDiscoveryService instance.
Types ¶
type AutoDiscoveryService ¶
AutoDiscoveryService encapsulates the libp2p host, DHT instance, and PubSub.
func InitializeNode ¶
func InitializeNode(ctx context.Context) (*AutoDiscoveryService, error)
InitializeNode creates a libp2p host with a DHT and PubSub instance, sets up mDNS discovery, and a stream handler for chat messages. It returns an AutoDiscoveryService.
func (*AutoDiscoveryService) AnnounceStorage ¶
func (s *AutoDiscoveryService) AnnounceStorage(storageGB int) error
AnnounceStorage publishes the node's storage contribution to the network using PubSub.
func (*AutoDiscoveryService) Start ¶
func (s *AutoDiscoveryService) Start(ctx context.Context)
Start initializes mDNS discovery, bootstraps the DHT, and starts the mDNS service.