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
5a2c0293
Commit
5a2c0293
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a few more cleanup changes to handlers
parent
70e025ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
18 deletions
+6
-18
dht/handlers.go
dht/handlers.go
+1
-18
dht/providers.go
dht/providers.go
+5
-0
No files found.
dht/handlers.go
View file @
5a2c0293
...
...
@@ -3,7 +3,6 @@ package dht
import
(
"errors"
"fmt"
"time"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
proto
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
...
...
@@ -63,9 +62,6 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
return
nil
,
err
}
// Note: changed the behavior here to return _as much_ info as possible
// (potentially all of {value, closer peers, provider})
// if we have the value, send it back
if
err
==
nil
{
log
.
Debugf
(
"%s handleGetValue success!"
,
dht
.
self
)
...
...
@@ -85,18 +81,10 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
resp
.
Record
=
rec
}
// if we know any providers for the requested value, return those.
provs
:=
dht
.
providers
.
GetProviders
(
ctx
,
u
.
Key
(
pmes
.
GetKey
()))
provinfos
:=
peer
.
PeerInfos
(
dht
.
peerstore
,
provs
)
if
len
(
provs
)
>
0
{
log
.
Debugf
(
"handleGetValue returning %d provider[s]"
,
len
(
provs
))
resp
.
ProviderPeers
=
pb
.
PeerInfosToPBPeers
(
dht
.
host
.
Network
(),
provinfos
)
}
// Find closest peer on given cluster to desired key and reply with that info
closer
:=
dht
.
betterPeersToQuery
(
pmes
,
p
,
CloserPeerCount
)
closerinfos
:=
peer
.
PeerInfos
(
dht
.
peerstore
,
closer
)
if
closer
!=
nil
{
closerinfos
:=
peer
.
PeerInfos
(
dht
.
peerstore
,
closer
)
for
_
,
pi
:=
range
closerinfos
{
log
.
Debugf
(
"handleGetValue returning closer peer: '%s'"
,
pi
.
ID
)
if
len
(
pi
.
Addrs
)
<
1
{
...
...
@@ -209,11 +197,6 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb.
return
resp
,
nil
}
type
providerInfo
struct
{
Creation
time
.
Time
Value
peer
.
ID
}
func
(
dht
*
IpfsDHT
)
handleAddProvider
(
ctx
context
.
Context
,
p
peer
.
ID
,
pmes
*
pb
.
Message
)
(
*
pb
.
Message
,
error
)
{
defer
log
.
EventBegin
(
ctx
,
"handleAddProvider"
,
p
)
.
Done
()
key
:=
u
.
Key
(
pmes
.
GetKey
())
...
...
This diff is collapsed.
Click to expand it.
dht/providers.go
View file @
5a2c0293
...
...
@@ -10,6 +10,11 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
)
type
providerInfo
struct
{
Creation
time
.
Time
Value
peer
.
ID
}
type
ProviderManager
struct
{
providers
map
[
u
.
Key
][]
*
providerInfo
local
map
[
u
.
Key
]
struct
{}
...
...
This diff is collapsed.
Click to expand it.
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