code auth added
This commit is contained in:
parent
f6576a9134
commit
9f655ba8c0
5 changed files with 127 additions and 145 deletions
|
@ -9,14 +9,19 @@ import (
|
|||
// 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, authCode, "update", "Start update process")
|
||||
for _, peerAddr := range peers {
|
||||
fmt.Printf("Notifying node %s about update...\n", peerAddr)
|
||||
msg := Message{
|
||||
ID: hostID.Pretty(),
|
||||
Type: "update",
|
||||
Content: "Start update process",
|
||||
}
|
||||
err := sendMessage(peerAddr, msg)
|
||||
if err != nil {
|
||||
log.Printf("Failed to notify node %s: %v\n", peer, err)
|
||||
log.Printf("Failed to notify node %s: %v\n", peerAddr, err)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("Node %s notified. Waiting for it to update...\n", peer)
|
||||
fmt.Printf("Node %s notified. Waiting for it to update...\n", peerAddr)
|
||||
time.Sleep(30 * time.Second) // Adjust sleep time as needed to allow for updates
|
||||
}
|
||||
fmt.Println("All nodes have been updated.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue