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
7622c4bb
Commit
7622c4bb
authored
Sep 16, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(bitswap) define Directory interface
parent
b36670df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
bitswap/bitswap.go
bitswap/bitswap.go
+3
-4
bitswap/interface.go
bitswap/interface.go
+6
-0
No files found.
bitswap/bitswap.go
View file @
7622c4bb
...
...
@@ -13,7 +13,6 @@ import (
blocks
"github.com/jbenet/go-ipfs/blocks"
blockstore
"github.com/jbenet/go-ipfs/blockstore"
peer
"github.com/jbenet/go-ipfs/peer"
routing
"github.com/jbenet/go-ipfs/routing"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -40,7 +39,7 @@ type bitswap struct {
blockstore
blockstore
.
Blockstore
// routing interface for communication
routing
routing
.
IpfsRouting
routing
Directory
notifications
notifications
.
PubSub
...
...
@@ -62,7 +61,7 @@ type bitswap struct {
}
// NewSession initializes a bitswap session.
func
NewSession
(
parent
context
.
Context
,
s
bsnet
.
NetworkService
,
p
*
peer
.
Peer
,
d
ds
.
Datastore
,
r
routing
.
IpfsRouting
)
Exchange
{
func
NewSession
(
parent
context
.
Context
,
s
bsnet
.
NetworkService
,
p
*
peer
.
Peer
,
d
ds
.
Datastore
,
directory
Directory
)
Exchange
{
receiver
:=
bsnet
.
Forwarder
{}
bs
:=
&
bitswap
{
...
...
@@ -70,7 +69,7 @@ func NewSession(parent context.Context, s bsnet.NetworkService, p *peer.Peer, d
blockstore
:
blockstore
.
NewBlockstore
(
d
),
partners
:
ledgerMap
{},
wantList
:
KeySet
{},
routing
:
r
,
routing
:
directory
,
sender
:
bsnet
.
NewNetworkAdapter
(
s
,
&
receiver
),
haltChan
:
make
(
chan
struct
{}),
notifications
:
notifications
.
New
(),
...
...
bitswap/interface.go
View file @
7622c4bb
...
...
@@ -4,6 +4,7 @@ import (
"time"
blocks
"github.com/jbenet/go-ipfs/blocks"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -20,3 +21,8 @@ type Exchange interface {
// whether the block was made available on the network?
HasBlock
(
blocks
.
Block
)
error
}
type
Directory
interface
{
FindProvidersAsync
(
u
.
Key
,
int
,
time
.
Duration
)
<-
chan
*
peer
.
Peer
Provide
(
key
u
.
Key
)
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