From 4284e8e9600adb8acd02f998bc111834b5a25382 Mon Sep 17 00:00:00 2001
From: Juan Batiz-Benet <juan@benet.ai>
Date: Fri, 19 Sep 2014 04:58:57 -0700
Subject: [PATCH] config: use PeerID in bootstrap config

---
 config/config.go |  1 +
 core/core.go     | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/config/config.go b/config/config.go
index 25f40ec9e..69b0a5a3b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -25,6 +25,7 @@ type Datastore struct {
 
 type SavedPeer struct {
 	Address string
+	PeerID  string // until multiaddr supports ipfs, use another field.
 }
 
 // Config is used to load IPFS config files.
diff --git a/core/core.go b/core/core.go
index 6712f6f83..3ada24f15 100644
--- a/core/core.go
+++ b/core/core.go
@@ -186,13 +186,21 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
 
 func initConnections(cfg *config.Config, route *dht.IpfsDHT) {
 	for _, p := range cfg.Peers {
+		if p.PeerID == "" {
+			u.PErr("error: peer does not include PeerID. %v\n", p)
+		}
+
 		maddr, err := ma.NewMultiaddr(p.Address)
 		if err != nil {
 			u.PErr("error: %v\n", err)
 			continue
 		}
 
-		_, err = route.Connect(maddr)
+		// setup peer
+		npeer := &peer.Peer{ID: peer.DecodePrettyID(p.PeerID)}
+		npeer.AddAddress(maddr)
+
+		_, err = route.Connect(npeer)
 		if err != nil {
 			u.PErr("Bootstrapping error: %v\n", err)
 		}
-- 
GitLab