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
3f63e50c
Commit
3f63e50c
authored
Dec 07, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(peer): use error-checking multiaddr method
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
9b73003b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
core/commands/swarm.go
core/commands/swarm.go
+5
-1
core/core.go
core/core.go
+5
-1
peer/peer.go
peer/peer.go
+6
-2
No files found.
core/commands/swarm.go
View file @
3f63e50c
...
...
@@ -149,8 +149,12 @@ func splitAddresses(addrs []string) (maddrs []ma.Multiaddr, pids []peer.ID, err
if
err
!=
nil
{
return
nil
,
nil
,
cmds
.
ClientError
(
"invalid peer address: "
+
err
.
Error
())
}
id
,
err
:=
peer
.
DecodePrettyID
(
path
.
Base
(
addr
))
if
err
!=
nil
{
return
nil
,
nil
,
err
}
pids
[
i
]
=
id
maddrs
[
i
]
=
a
pids
[
i
]
=
peer
.
DecodePrettyID
(
path
.
Base
(
addr
))
}
return
}
...
...
core/core.go
View file @
3f63e50c
...
...
@@ -265,7 +265,11 @@ func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerst
}
// setup peer
npeer
,
err
:=
pstore
.
Get
(
peer
.
DecodePrettyID
(
p
.
PeerID
))
id
,
err
:=
peer
.
DecodePrettyID
(
p
.
PeerID
)
if
err
!=
nil
{
// return err
}
npeer
,
err
:=
pstore
.
Get
(
id
)
if
err
!=
nil
{
log
.
Criticalf
(
"Bootstrapping error: %v"
,
err
)
continue
...
...
peer/peer.go
View file @
3f63e50c
...
...
@@ -37,8 +37,12 @@ func (id ID) Pretty() string {
}
// DecodePrettyID returns a b58-encoded string of the ID
func
DecodePrettyID
(
s
string
)
ID
{
return
b58
.
Decode
(
s
)
func
DecodePrettyID
(
s
string
)
(
ID
,
error
)
{
m
,
err
:=
mh
.
FromB58String
(
s
)
if
err
!=
nil
{
return
nil
,
err
}
return
ID
(
m
),
err
}
// IDFromPubKey retrieves a Public Key from the peer given by pk
...
...
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