@cryptotaxi247 / kubo / commits / 05346dd92

misc(core/identity) more specific function argument

to aid in testing

Brian Tiger Chow committed Nov 11, 2014 at 15:53 UTC 05346dd927d7d5b8f2142ceb6b4da71d435c2f2f
1 file changed +6 -6
core/core.go
+6 -6
@@ -121,7 +121,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
121
122 // setup peerstore + local peer identity
123 n.Peerstore = peer.NewPeerstore()
124 - n.Identity, err = initIdentity(n.Config, n.Peerstore, online)
124 + n.Identity, err = initIdentity(&n.Config.Identity, n.Peerstore, online)
125 if err != nil {
126 return nil, err
127 }
@@ -196,17 +196,17 @@ func (n *IpfsNode) OnlineMode() bool {
196 return n.onlineMode
197 }
198
199 -func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) {
200 - if cfg.Identity.PeerID == "" {
199 +func initIdentity(cfg *config.Identity, peers peer.Peerstore, online bool) (peer.Peer, error) {
200 + if cfg.PeerID == "" {
201 return nil, errors.New("Identity was not set in config (was ipfs init run?)")
202 }
203
204 - if len(cfg.Identity.PeerID) == 0 {
204 + if len(cfg.PeerID) == 0 {
205 return nil, errors.New("No peer ID in config! (was ipfs init run?)")
206 }
207
208 // get peer from peerstore (so it is constructed there)
209 - id := peer.ID(b58.Decode(cfg.Identity.PeerID))
209 + id := peer.ID(b58.Decode(cfg.PeerID))
210 self, err := peers.Get(id)
211 if err != nil {
212 return nil, err
@@ -214,7 +214,7 @@ func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.P
214
215 // when not online, don't need to parse private keys (yet)
216 if online {
217 - skb, err := base64.StdEncoding.DecodeString(cfg.Identity.PrivKey)
217 + skb, err := base64.StdEncoding.DecodeString(cfg.PrivKey)
218 if err != nil {
219 return nil, err
220 }