core: Don't require address for node initialization
Matt Bell committed
Sep 11, 2014 at 17:48 UTC
b63e10f3b5d72d415329e49757cdbd8ce54669c8
1 file changed
+10
-4
core/core.go
+10
-4
@@ -122,9 +122,15 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
122
return nil, errors.New("No peer ID in config! (was ipfs init run?)")
123
}
124
125
- maddr, err := ma.NewMultiaddr(cfg.Identity.Address)
126
- if err != nil {
127
- return nil, err
125
+ // address is optional
126
+ var addresses []*ma.Multiaddr
127
+ if len(cfg.Identity.Address) > 0 {
128
+ maddr, err := ma.NewMultiaddr(cfg.Identity.Address)
129
+ if err != nil {
130
+ return nil, err
131
+ }
132
+
133
+ addresses = []*ma.Multiaddr{ maddr }
134
}
135
136
skb, err := base64.StdEncoding.DecodeString(cfg.Identity.PrivKey)
@@ -139,7 +145,7 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
145
146
return &peer.Peer{
147
ID: peer.ID(b58.Decode(cfg.Identity.PeerID)),
142
- Addresses: []*ma.Multiaddr{maddr},
148
+ Addresses: addresses,
149
PrivKey: sk,
150
PubKey: sk.GetPublic(),
151
}, nil