func initializeAddressList() error { err := getLocalIP() if err != nil { log.Fatal(err) return err } path := util.ConfPath("peerlist") file, err := os.Open(path) if err != nil && os.IsNotExist(err) { if !Settings.DoNotBootStrap { bootStrap() //This bootstraps us into the network } else { var ipList addresslist.PeerList AddressList = addresslist.New(ipList) log.Println("Created empty AddressList") } return nil } else if err != nil { log.Fatal(err) } else { data, err := ioutil.ReadAll(file) if err != nil { log.Fatal(err) return err } ipList := addresslist.Unmarshal(data) AddressList = addresslist.New(ipList) log.Println("Loaded AddressList from file") } return err }
func GetPeerList(address net.IP) (addresslist.PeerList, error) { resp, err := get(address, "/peerlist") if err != nil { log.Println(err) return nil, err } peerlist := addresslist.Unmarshal(resp) return peerlist, err }