@cryptotaxi247 / kubo / commits / 4284e8e96

config: use PeerID in bootstrap config

Juan Batiz-Benet committed Sep 19, 2014 at 04:58 UTC 4284e8e9600adb8acd02f998bc111834b5a25382
2 files changed +10 -1
config/config.go
+1
@@ -25,6 +25,7 @@ type Datastore struct {
25
26 type SavedPeer struct {
27 Address string
28 + PeerID string // until multiaddr supports ipfs, use another field.
29 }
30
31 // Config is used to load IPFS config files.
core/core.go
+9 -1
@@ -186,13 +186,21 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
186
187 func initConnections(cfg *config.Config, route *dht.IpfsDHT) {
188 for _, p := range cfg.Peers {
189 + if p.PeerID == "" {
190 + u.PErr("error: peer does not include PeerID. %v\n", p)
191 + }
192 +
193 maddr, err := ma.NewMultiaddr(p.Address)
194 if err != nil {
195 u.PErr("error: %v\n", err)
196 continue
197 }
198
195 - _, err = route.Connect(maddr)
199 + // setup peer
200 + npeer := &peer.Peer{ID: peer.DecodePrettyID(p.PeerID)}
201 + npeer.AddAddress(maddr)
202 +
203 + _, err = route.Connect(npeer)
204 if err != nil {
205 u.PErr("Bootstrapping error: %v\n", err)
206 }