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
8e381d55
Unverified
Commit
8e381d55
authored
Apr 18, 2019
by
Steven Allen
Committed by
GitHub
Apr 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6234 from ipfs/chore/filter-optimization
fix two small nits in the go-ipfs constructor
parents
c3a7bc26
d83374fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
core/node/libp2p.go
core/node/libp2p.go
+10
-6
No files found.
core/node/libp2p.go
View file @
8e381d55
...
...
@@ -84,15 +84,19 @@ var DHTOption RoutingOption = constructDHTRouting
var
DHTClientOption
RoutingOption
=
constructClientDHTRouting
var
NilRouterOption
RoutingOption
=
nilrouting
.
ConstructNilRouting
func
Peerstore
(
id
peer
.
ID
,
sk
crypto
.
PrivKey
)
peerstore
.
Peerstore
{
func
Peerstore
(
id
peer
.
ID
,
sk
crypto
.
PrivKey
)
(
peerstore
.
Peerstore
,
error
)
{
ps
:=
pstoremem
.
NewPeerstore
()
if
sk
!=
nil
{
ps
.
AddPrivKey
(
id
,
sk
)
ps
.
AddPubKey
(
id
,
sk
.
GetPublic
())
if
err
:=
ps
.
AddPubKey
(
id
,
sk
.
GetPublic
());
err
!=
nil
{
return
nil
,
err
}
if
err
:=
ps
.
AddPrivKey
(
id
,
sk
);
err
!=
nil
{
return
nil
,
err
}
}
return
ps
return
ps
,
nil
}
func
P2PAddrFilters
(
cfg
*
config
.
Config
)
(
opts
Libp2pOpts
,
err
error
)
{
...
...
@@ -198,7 +202,7 @@ func makeAddrsFactory(cfg config.Addresses) (p2pbhost.AddrsFactory, error) {
if
err
!=
nil
{
return
nil
,
err
}
noAnnAddrs
[
maddr
.
String
(
)]
=
true
noAnnAddrs
[
string
(
maddr
.
Bytes
()
)]
=
true
}
return
func
(
allAddrs
[]
ma
.
Multiaddr
)
[]
ma
.
Multiaddr
{
...
...
@@ -212,7 +216,7 @@ func makeAddrsFactory(cfg config.Addresses) (p2pbhost.AddrsFactory, error) {
var
out
[]
ma
.
Multiaddr
for
_
,
maddr
:=
range
addrs
{
// check for exact matches
ok
:=
noAnnAddrs
[
maddr
.
String
(
)]
ok
:=
noAnnAddrs
[
string
(
maddr
.
Bytes
()
)]
// check for /ipcidr matches
if
!
ok
&&
!
filters
.
AddrBlocked
(
maddr
)
{
out
=
append
(
out
,
maddr
)
...
...
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