mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-23 05:07:51 +01:00
Initial working Kademlia network - peer list exchange is working!
Using the announcement and response messages to exchange peer lists. Fixes in encoding. Add arbitrary Info structure to DHT Lite/Node.
This commit is contained in:
16
Bootstrap.go
16
Bootstrap.go
@@ -91,8 +91,13 @@ func parseAddress(Address string) (remote *net.UDPAddr, err error) {
|
||||
|
||||
// contact tries to contact the root peer on all networks
|
||||
func (peer *rootPeer) contact() {
|
||||
packets, err := msgEncodeAnnouncement(true, true, nil, nil, nil)
|
||||
if len(packets) == 0 || err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, address := range peer.addresses {
|
||||
sendAllNetworks(peer.publicKey, &PacketRaw{Command: 0}, address)
|
||||
sendAllNetworks(peer.publicKey, &PacketRaw{Command: CommandAnnouncement, Payload: packets[0]}, address)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,3 +193,12 @@ func autoMulticastBroadcast() {
|
||||
sendMulticastBroadcast()
|
||||
}
|
||||
}
|
||||
|
||||
func contactArbitraryPeer(publicKey *btcec.PublicKey, ip net.IP, port uint16) {
|
||||
packets, err := msgEncodeAnnouncement(true, true, nil, nil, nil)
|
||||
if len(packets) == 0 || err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
sendAllNetworks(publicKey, &PacketRaw{Command: CommandAnnouncement, Payload: packets[0]}, &net.UDPAddr{IP: ip, Port: int(port)})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user