added fixed adding duplicate structs to IP table

This commit is contained in:
2021-04-08 20:39:50 +04:00
parent 2b2290ecea
commit bc1859484a
3 changed files with 9 additions and 7 deletions

View File

@@ -45,13 +45,16 @@ func UpdateIpTableListClient() error {
return err
}
// IP addresses to not read from
var DoNotRead p2p.IpAddresses
// IP addresses to not append to struct due to
// duplication
Addresses, err := p2p.ReadIpTable()
DoNotRead := Addresses
// Run loop 3 times
for i := 0; i < 3; i++ {
// Gets information from IP table
Addresses, err := p2p.ReadIpTable()
Addresses, err = p2p.ReadIpTable()
if err != nil {
return err
}

BIN
p2p-rendering-computation Executable file

Binary file not shown.

View File

@@ -1,7 +1,5 @@
package p2p
import "fmt"
// Runs a speed test and does updates IP tables accordingly
func (ip *IpAddresses)SpeedTest() error{
@@ -25,7 +23,6 @@ func (ip *IpAddresses)SpeedTest() error{
if err != nil {
return err
}
fmt.Println(ip.IpAddress[i].Latency)
}
err := ip.WriteIpTable()
@@ -43,7 +40,9 @@ func (ip *IpAddresses)SpeedTestUpdatedIPTable() error{
return err
}
var DoNotRead IpAddresses
// To ensure struct has no duplicates IP addresses
DoNotRead := targets
// Appends all IP addresses
for i, _ := range targets.IpAddress {