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
p2p
go-p2p-kad-dht
Commits
5a05448e
Commit
5a05448e
authored
Jul 11, 2017
by
Jeromy Johnson
Committed by
GitHub
Jul 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #65 from libp2p/feat/pubkey-extract
Feat/pubkey extract
parents
c3110959
95a3e5da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
23 deletions
+63
-23
package.json
package.json
+22
-22
records.go
records.go
+7
-1
records_test.go
records_test.go
+34
-0
No files found.
package.json
View file @
5a05448e
...
...
@@ -14,15 +14,15 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
P1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY
"
,
"hash"
:
"Qm
aPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo
"
,
"name"
:
"go-libp2p-crypto"
,
"version"
:
"1.
4.2
"
"version"
:
"1.
5.0
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
dS9KpbDyPrieswibZhkod1oXqRwZJrUPzxCofAMWpFGq
"
,
"hash"
:
"Qm
XYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB
"
,
"name"
:
"go-libp2p-peer"
,
"version"
:
"2.
1.7
"
"version"
:
"2.
2.0
"
},
{
"hash"
:
"QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP"
,
...
...
@@ -60,9 +60,9 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
XZSd1qR5BxZkPyuwfT5jpqQFScZccoZvDneXsKzCNHWX
"
,
"hash"
:
"Qm
PgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr
"
,
"name"
:
"go-libp2p-peerstore"
,
"version"
:
"1.4.
8
"
"version"
:
"1.4.
9
"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -84,27 +84,27 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
dVnYKahrvndXhyreWhY8YT3a5chJoWv8b4wVyH9JG2KB
"
,
"hash"
:
"Qm
SXpwmggGd8fe7e9abqRuST7SqaZjrz3Cg5avMJbdmKGe
"
,
"name"
:
"go-testutil"
,
"version"
:
"1.1.
7
"
"version"
:
"1.1.
8
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
WYCqr6UDqqD1bfRybaAPtbAqcN3TSJpveaBXMwbQ3ePZ
"
,
"hash"
:
"Qm
bxkgUceEcuSZ4ZdBA3x74VUDSSYjHYmmeEqkjxbtZ6Jg
"
,
"name"
:
"go-libp2p-record"
,
"version"
:
"2.1.
4
"
"version"
:
"2.1.
5
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
aQG6fJdzn2532WHoPdVwKqftXr6iCSr5NtWyGi1BHytT
"
,
"hash"
:
"Qm
biCMdwmmhif5axuGSHzYbPFGeKjLAuMY6JrGpVteHFsy
"
,
"name"
:
"go-libp2p-kbucket"
,
"version"
:
"2.1.
9
"
"version"
:
"2.1.
10
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmP
1wMAqk6aZYRZirbaAwmrNeqFRgQrwBt3orUtvSa1UYD
"
,
"hash"
:
"QmP
jTrrSfE6TzLv6ya6VWhGcCgPrUAdcgrDcQyRDX2VyW1
"
,
"name"
:
"go-libp2p-routing"
,
"version"
:
"2.2.1
6
"
"version"
:
"2.2.1
7
"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -114,27 +114,27 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
a4RJSuh7mMeJQYCqMbKzekn6EwBo7HEs5AQYjVRMQATB
"
,
"hash"
:
"Qm
TprEaAA2A9bst5XH7exuyi5KzNMK3SEDNN8rBDnKWcUS
"
,
"name"
:
"go-cid"
,
"version"
:
"0.7.1
6
"
"version"
:
"0.7.1
7
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
VesPmqbPp7xRGyY96tnBwzDtVV1nqv4SCVxo5zCqKyH8
"
,
"hash"
:
"Qm
T4PgCNdv73hnFAqzHqwW44q7M9PWpykSswHDxndquZbc
"
,
"name"
:
"go-libp2p-loggables"
,
"version"
:
"1.1.
7
"
"version"
:
"1.1.
8
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
UywuGNZoUKV8B9iyvup9bPkLiMrhTsyVMkeSXW5VxAfC
"
,
"hash"
:
"Qm
Zy7c24mmkEHpNJndwgsEE3wcVxHd8yB969yTnAJFVw7f
"
,
"name"
:
"go-libp2p-host"
,
"version"
:
"1.3.1
4
"
"version"
:
"1.3.1
5
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
QA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime
"
,
"hash"
:
"Qm
apADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9
"
,
"name"
:
"go-libp2p"
,
"version"
:
"4.
3
.1
2
"
"version"
:
"4.
4
.1"
}
],
"gxVersion"
:
"0.4.0"
,
...
...
records.go
View file @
5a05448e
...
...
@@ -24,8 +24,14 @@ const MaxRecordAge = time.Hour * 36
func
(
dht
*
IpfsDHT
)
GetPublicKey
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
ci
.
PubKey
,
error
)
{
log
.
Debugf
(
"getPublicKey for: %s"
,
p
)
// try extracting from identity.
pk
:=
p
.
ExtractPublicKey
()
if
pk
!=
nil
{
return
pk
,
nil
}
// check locally.
pk
:
=
dht
.
peerstore
.
PubKey
(
p
)
pk
=
dht
.
peerstore
.
PubKey
(
p
)
if
pk
!=
nil
{
return
pk
,
nil
}
...
...
records_test.go
0 → 100644
View file @
5a05448e
package
dht
import
(
"context"
"crypto/rand"
"testing"
ci
"github.com/libp2p/go-libp2p-crypto"
peer
"github.com/libp2p/go-libp2p-peer"
)
func
TestPubkeyExtract
(
t
*
testing
.
T
)
{
_
,
pk
,
err
:=
ci
.
GenerateEd25519Key
(
rand
.
Reader
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
pid
,
err
:=
peer
.
IDFromEd25519PublicKey
(
pk
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// no need to actually construct one
d
:=
new
(
IpfsDHT
)
pk_out
,
err
:=
d
.
GetPublicKey
(
context
.
Background
(),
pid
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
pk_out
.
Equals
(
pk
)
{
t
.
Fatal
(
"got incorrect public key out"
)
}
}
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