Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
91c1aaa1
Commit
91c1aaa1
authored
Oct 19, 2020
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: do not create and print out an unused new peerID when initializing from a config
parent
af089dee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
34 deletions
+34
-34
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+12
-6
cmd/ipfs/init.go
cmd/ipfs/init.go
+22
-28
No files found.
cmd/ipfs/daemon.go
View file @
91c1aaa1
...
...
@@ -250,14 +250,20 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
}
}
identity
,
err
:=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Type
(
algorithmDefault
),
})
if
err
!=
nil
{
return
err
if
conf
==
nil
{
identity
,
err
:=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Type
(
algorithmDefault
),
})
if
err
!=
nil
{
return
err
}
conf
,
err
=
config
.
InitWithIdentity
(
identity
)
if
err
!=
nil
{
return
err
}
}
if
err
=
doInit
(
os
.
Stdout
,
cctx
.
ConfigRoot
,
false
,
&
identity
,
profiles
,
conf
);
err
!=
nil
{
if
err
=
doInit
(
os
.
Stdout
,
cctx
.
ConfigRoot
,
false
,
profiles
,
conf
);
err
!=
nil
{
return
err
}
}
...
...
cmd/ipfs/init.go
View file @
91c1aaa1
...
...
@@ -113,24 +113,30 @@ environment variable:
}
}
var
err
error
var
identity
config
.
Identity
if
nBitsGiven
{
identity
,
err
=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Size
(
nBitsForKeypair
),
options
.
Key
.
Type
(
algorithm
),
})
}
else
{
identity
,
err
=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Type
(
algorithm
),
})
}
if
err
!=
nil
{
return
err
if
conf
==
nil
{
var
err
error
var
identity
config
.
Identity
if
nBitsGiven
{
identity
,
err
=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Size
(
nBitsForKeypair
),
options
.
Key
.
Type
(
algorithm
),
})
}
else
{
identity
,
err
=
config
.
CreateIdentity
(
os
.
Stdout
,
[]
options
.
KeyGenerateOption
{
options
.
Key
.
Type
(
algorithm
),
})
}
if
err
!=
nil
{
return
err
}
conf
,
err
=
config
.
InitWithIdentity
(
identity
)
if
err
!=
nil
{
return
err
}
}
profiles
,
_
:=
req
.
Options
[
profileOptionName
]
.
(
string
)
return
doInit
(
os
.
Stdout
,
cctx
.
ConfigRoot
,
empty
,
&
identity
,
profiles
,
conf
)
return
doInit
(
os
.
Stdout
,
cctx
.
ConfigRoot
,
empty
,
profiles
,
conf
)
},
}
...
...
@@ -152,7 +158,7 @@ func applyProfiles(conf *config.Config, profiles string) error {
return
nil
}
func
doInit
(
out
io
.
Writer
,
repoRoot
string
,
empty
bool
,
identity
*
config
.
Identity
,
confProfiles
string
,
conf
*
config
.
Config
)
error
{
func
doInit
(
out
io
.
Writer
,
repoRoot
string
,
empty
bool
,
confProfiles
string
,
conf
*
config
.
Config
)
error
{
if
_
,
err
:=
fmt
.
Fprintf
(
out
,
"initializing IPFS node at %s
\n
"
,
repoRoot
);
err
!=
nil
{
return
err
}
...
...
@@ -165,18 +171,6 @@ func doInit(out io.Writer, repoRoot string, empty bool, identity *config.Identit
return
errRepoExists
}
if
identity
==
nil
{
return
fmt
.
Errorf
(
"No Identity provided for initialization"
)
}
if
conf
==
nil
{
var
err
error
conf
,
err
=
config
.
InitWithIdentity
(
*
identity
)
if
err
!=
nil
{
return
err
}
}
if
err
:=
applyProfiles
(
conf
,
confProfiles
);
err
!=
nil
{
return
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment