mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-23 13:44:27 +08:00
config: use PeerID in bootstrap config
This commit is contained in:

committed by
Brian Tiger Chow

parent
9ea715cb10
commit
4284e8e960
@ -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.
|
||||
|
10
core/core.go
10
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user