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-routing
Commits
fdf7dbf6
Commit
fdf7dbf6
authored
Mar 30, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache public keys and use better method for fetching
parent
64d49feb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
dht/records.go
dht/records.go
+2
-3
routing.go
routing.go
+5
-0
No files found.
dht/records.go
View file @
fdf7dbf6
...
...
@@ -18,7 +18,7 @@ func KeyForPublicKey(id peer.ID) u.Key {
return
u
.
Key
(
"/pk/"
+
string
(
id
))
}
func
(
dht
*
IpfsDHT
)
g
etPublicKey
Online
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
ci
.
PubKey
,
error
)
{
func
(
dht
*
IpfsDHT
)
G
etPublicKey
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
ci
.
PubKey
,
error
)
{
log
.
Debugf
(
"getPublicKey for: %s"
,
p
)
// check locally.
...
...
@@ -42,7 +42,6 @@ func (dht *IpfsDHT) getPublicKeyOnline(ctx context.Context, p peer.ID) (ci.PubKe
log
.
Debugf
(
"pk for %s not in peerstore, and peer failed. trying dht."
,
p
)
pkkey
:=
KeyForPublicKey
(
p
)
// ok, now try the dht. Anyone who has previously fetched the key should have it
val
,
err
:=
dht
.
GetValue
(
ctxT
,
pkkey
)
if
err
!=
nil
{
log
.
Warning
(
"Failed to find requested public key."
)
...
...
@@ -132,7 +131,7 @@ func (dht *IpfsDHT) verifyRecordOnline(ctx context.Context, r *pb.Record) error
if
len
(
r
.
Signature
)
>
0
{
// get the public key, search for it if necessary.
p
:=
peer
.
ID
(
r
.
GetAuthor
())
pk
,
err
:=
dht
.
g
etPublicKey
Online
(
ctx
,
p
)
pk
,
err
:=
dht
.
G
etPublicKey
(
ctx
,
p
)
if
err
!=
nil
{
return
err
}
...
...
routing.go
View file @
fdf7dbf6
...
...
@@ -6,6 +6,7 @@ import (
"time"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
ci
"github.com/ipfs/go-ipfs/p2p/crypto"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
u
"github.com/ipfs/go-ipfs/util"
)
...
...
@@ -46,3 +47,7 @@ type IpfsRouting interface {
// TODO expose io.Closer or plain-old Close error
}
type
PubKeyFetcher
interface
{
GetPublicKey
(
context
.
Context
,
peer
.
ID
)
(
ci
.
PubKey
,
error
)
}
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