node update sync wip

This commit is contained in:
partisan 2024-06-30 23:20:52 +02:00
parent 30aa3d0238
commit 8f913eca0d
5 changed files with 189 additions and 45 deletions

23
node-update.go Normal file
View file

@ -0,0 +1,23 @@
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.")
}