Skip to content

Commit

Permalink
Implements ignoring duplicate peers when bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashy5000 committed Apr 1, 2024
1 parent 40a7b6a commit 319d195
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ func Bootstrap() {
var peerPeers []string
err = json.Unmarshal(peerPeersBytes, &peerPeers)
for _, peerPeer := range peerPeers {
// Add the peer's peers to the list of peers
AddPeer(peerPeer)
if !PeerKnown(peerPeer) {
// Add the peer's peers to the list of peers
AddPeer(peerPeer)
}
}
}
}
Binary file modified builds/node/node_darwin-amd64
Binary file not shown.
Binary file modified builds/node/node_darwin-arm64
Binary file not shown.
Binary file modified builds/node/node_linux-386
Binary file not shown.
Binary file modified builds/node/node_linux-amd64
Binary file not shown.
Binary file modified builds/node/node_linux-arm
Binary file not shown.
Binary file modified builds/node/node_linux-arm64
Binary file not shown.
Binary file modified builds/node/node_windows-386
Binary file not shown.
Binary file modified builds/node/node_windows-amd64
Binary file not shown.
Binary file modified builds/node/node_windows-arm
Binary file not shown.
Binary file modified builds/node/node_windows-arm64
Binary file not shown.
10 changes: 10 additions & 0 deletions peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ func GetPeers() []string {
return result
}
}

func PeerKnown(ip string) bool {
peers := GetPeers()
for _, peer := range peers {
if peer == ip {
return true
}
}
return false
}
2 changes: 1 addition & 1 deletion peers.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
http://192.168.4.87:8080
http://192.168.4.23:8080
http://192.168.4.23:8080

0 comments on commit 319d195

Please sign in to comment.