Search/node-update.go

24 lines
624 B
Go
Raw Normal View History

2024-06-30 21:20:52 +00:00
package main
import (
"fmt"
"log"
"time"
)
// Function to sync updates across all nodes
func nodeUpdateSync() {
fmt.Println("Syncing updates across all nodes...")
for _, peer := range peers {
fmt.Printf("Notifying node %s about update...\n", peer)
err := sendMessage(peer, connCode, "update", "Start update process")
if err != nil {
log.Printf("Failed to notify node %s: %v\n", peer, err)
continue
}
fmt.Printf("Node %s notified. Waiting for it to update...\n", peer)
time.Sleep(30 * time.Second) // Adjust sleep time as needed to allow for updates
}
fmt.Println("All nodes have been updated.")
}