1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-23 05:35:58 +08:00

config: use PeerID in bootstrap config

This commit is contained in:
Juan Batiz-Benet
2014-09-19 04:58:57 -07:00
committed by Brian Tiger Chow
parent 9ea715cb10
commit 4284e8e960
2 changed files with 10 additions and 1 deletions

View File

@ -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.

View File

@ -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)
}