@cryptotaxi247 / kubo / commits / 8c35988b8

add bootstrap peers to peerstore.

Juan Batiz-Benet committed Sep 21, 2014 at 03:49 UTC 8c35988b8d91fbd1d46af62807d083c49f1378e3
1 file changed +8 -4
core/core.go
+8 -4
@@ -121,7 +121,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
121 exchangeSession = bitswap.NetMessageSession(ctx, exchangeService, local, d, route)
122
123 // TODO(brian): pass a context to initConnections
124 - go initConnections(cfg, route)
124 + go initConnections(cfg, peerstore, route)
125 }
126
127 // TODO(brian): when offline instantiate the BlockService with a bitswap
@@ -184,7 +184,7 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
184 }, nil
185 }
186
187 -func initConnections(cfg *config.Config, route *dht.IpfsDHT) {
187 +func initConnections(cfg *config.Config, pstore peer.Peerstore, 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)
@@ -200,8 +200,12 @@ func initConnections(cfg *config.Config, route *dht.IpfsDHT) {
200 npeer := &peer.Peer{ID: peer.DecodePrettyID(p.PeerID)}
201 npeer.AddAddress(maddr)
202
203 - _, err = route.Connect(npeer)
204 - if err != nil {
203 + if err = pstore.Put(npeer); err != nil {
204 + u.PErr("Bootstrapping error: %v\n", err)
205 + continue
206 + }
207 +
208 + if _, err = route.Connect(npeer); err != nil {
209 u.PErr("Bootstrapping error: %v\n", err)
210 }
211 }