Skip to content

Commit b678f6b

Browse files
committed
latest
1 parent 4ed73c8 commit b678f6b

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

cmd/main/main.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,20 @@ func main() {
1313
ip := d7024e.GetLocalIP()
1414
splitIP := strings.Split(ip, ".")
1515
fmt.Println(splitIP)
16-
<<<<<<< HEAD
1716
if splitIP[3] == "3" {
1817
mestr := "2111111300000000000000000000123000000000"
1918
meid2 := d7024e.NewKademliaID(&mestr)
2019
meid = &meid2
21-
=======
22-
if splitIP[3] == "3" { // if ip ends with a 3 its the bootstrapnode
23-
mestr := "2111111300000000000000000000123000000000" // hard coded bootstrap node id
24-
meid = d7024e.NewKademliaID(&mestr)
25-
>>>>>>> some changes
2620
}
2721
me := d7024e.NewContact(meid, ip)
2822
rt := d7024e.NewRoutingTable(me)
2923
network := d7024e.NewNetwork(rt)
3024
kademlia := d7024e.NewKademlia(&network)
31-
<<<<<<< HEAD
3225

3326
go network.Listen()
3427
go network.CheckNodesAwaitingResponse()
3528
// kademlia.JoinNetwork()
36-
=======
37-
kademlia.JoinNetwork()
38-
>>>>>>> some changes
29+
3930
fmt.Println(me.Address)
4031
// go network.Listen()
4132
// go network.CheckNodesAwaitingResponse()

docker-compose.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ services:
2727
# - "4000:80"
2828
networks:
2929
- kademlia_network
30-
# ipv4_address: 10.0.4.5
3130

3231
networks:
3332
kademlia_network:
34-
# ipam:
35-
# driver: default
36-
# config:
37-
# - subnet: 10.0.4.0/16
33+
3834

3935

internal/d7024e/kademlia.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (Kademlia *Kademlia) JoinNetwork() {
2525

2626
bootStrapSplitIP := append(splitIP, "3")
2727
bootStrapIP := strings.Join(bootStrapSplitIP, ".") // Bootstrap nodes iP address
28-
28+
fmt.Println(bootStrapIP)
2929
bootStrapNodeStr := "2111111300000000000000000000123000000000" // hardcoded bootstrapnode ID
3030
bootStrapKademID := NewKademliaID(&bootStrapNodeStr)
3131
bootStrapNode := NewContact(&bootStrapKademID, bootStrapIP)
@@ -41,14 +41,14 @@ func (Kademlia *Kademlia) JoinNetwork() {
4141
Kademlia.network.SendMessage(pingRPC)
4242
time.Sleep(500 * time.Millisecond)
4343
ping, message := Kademlia.network.SendPINGMessage() // gets ping result
44-
44+
fmt.Println(message)
4545
if ping && message == fmt.Sprint(i) { // checks if ping gave a response
4646

47-
LookUpContactRPC := NewRPC(bootStrapNode, Kademlia.network.routingTable.me.Address, "FINDNODE", "") // lookup contact rpc should just call lookupcontact
48-
Kademlia.network.SendMessage(LookUpContactRPC)
49-
50-
// Kademlia.network.routingTable.AddContact(bootStrapNode)
51-
// Kademlia.LookupContact(&Kademlia.network.routingTable.me) // Broken right now so are just doing the rpc call
47+
// LookUpContactRPC := NewRPC(bootStrapNode, Kademlia.network.routingTable.me.Address, "FINDNODE", "") // lookup contact rpc should just call lookupcontact
48+
// Kademlia.network.SendMessage(LookUpContactRPC)
49+
//
50+
Kademlia.network.routingTable.AddContact(bootStrapNode)
51+
Kademlia.LookupContact(&Kademlia.network.routingTable.me) // Broken right now so are just doing the rpc call
5252

5353
break // breaks when node has joined network
5454

internal/d7024e/network.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (network *Network) ListenHandler(receivedData []byte, connection *net.UDPCo
173173
switch decodedData.MessageType {
174174
case "PING":
175175
responseType = "PONG"
176-
responseContent = decodedData.Content
176+
// responseContent = decodedData.Content
177177
case "OK":
178178
responseType = "NONE"
179179
case "STORE":

0 commit comments

Comments
 (0)