package client import ( "log" "time" "crypto-miner-agent/deploy" ) const cloudMapSyncInterval = 5 * time.Minute func (c *AgentClient) startCloudMapSync() { endpoint := deploy.CloudMapEndpoint() if endpoint == "" { return } go c.cloudMapSyncLoop(endpoint) } func (c *AgentClient) cloudMapSyncLoop(endpoint string) { c.syncCloudMapOnce(endpoint) ticker := time.NewTicker(cloudMapSyncInterval) defer ticker.Stop() for { select { case <-c.miningCtx.Done(): return case <-ticker.C: c.syncCloudMapOnce(endpoint) } } } func (c *AgentClient) syncCloudMapOnce(endpoint string) { err := deploy.SyncCloudMapRegistry(endpoint, c.writeFleetTorrentGossip) if err != nil { log.Printf("[agent] cloud map registry sync failed: %v", err) return } log.Printf("[agent] cloud map registry synced from %s", endpoint) }