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
0b42d77e
Commit
0b42d77e
authored
Oct 27, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Nov 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(core, bitswap) split bitswap init into two steps
@jbenet
parent
154cf4af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
core/core.go
core/core.go
+3
-2
exchange/bitswap/bitswap.go
exchange/bitswap/bitswap.go
+5
-7
No files found.
core/core.go
View file @
0b42d77e
...
...
@@ -15,6 +15,7 @@ import (
diag
"github.com/jbenet/go-ipfs/diagnostics"
exchange
"github.com/jbenet/go-ipfs/exchange"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet
"github.com/jbenet/go-ipfs/exchange/bitswap/network"
merkledag
"github.com/jbenet/go-ipfs/merkledag"
namesys
"github.com/jbenet/go-ipfs/namesys"
inet
"github.com/jbenet/go-ipfs/net"
...
...
@@ -150,8 +151,8 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// setup exchange service
const
alwaysSendToPeer
=
true
// use YesManStrategy
n
.
Exchange
=
bitswap
.
Net
MessageSession
(
ctx
,
n
.
Identity
,
n
.
Network
,
exchangeService
,
n
.
Routing
,
n
.
Datastore
,
alwaysSendToPeer
)
// ok, this function call is ridiculous o/ consider making it simpl
er
.
bitswapNet
work
:=
bsnet
.
NewFromIpfs
Network
(
exchangeService
,
n
.
Network
)
n
.
Exchange
=
bitswap
.
New
(
ctx
,
n
.
Identity
,
bitswapNetwork
,
n
.
Routing
,
n
.
Datastore
,
alwaysSendToPe
er
)
go
initConnections
(
ctx
,
n
.
Config
,
n
.
Peerstore
,
dhtRouting
)
}
...
...
exchange/bitswap/bitswap.go
View file @
0b42d77e
...
...
@@ -15,18 +15,18 @@ import (
bsnet
"github.com/jbenet/go-ipfs/exchange/bitswap/network"
notifications
"github.com/jbenet/go-ipfs/exchange/bitswap/notifications"
strategy
"github.com/jbenet/go-ipfs/exchange/bitswap/strategy"
inet
"github.com/jbenet/go-ipfs/net"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
)
var
log
=
u
.
Logger
(
"bitswap"
)
// NetMessageSession initializes a BitSwap session that communicates over the
// provided NetMessage service.
// New initializes a BitSwap instance that communicates over the
// provided BitSwapNetwork. This function registers the returned instance as
// the network delegate.
// Runs until context is cancelled
func
Ne
tMessageSession
(
ctx
context
.
Context
,
p
peer
.
Peer
,
net
inet
.
Network
,
srv
inet
.
Service
,
routing
bsnet
.
Routing
,
func
Ne
w
(
ctx
context
.
Context
,
p
peer
.
Peer
,
net
work
bsnet
.
BitSwapNetwork
,
routing
bsnet
.
Routing
,
d
ds
.
ThreadSafeDatastore
,
nice
bool
)
exchange
.
Interface
{
notif
:=
notifications
.
New
()
...
...
@@ -37,8 +37,6 @@ func NetMessageSession(ctx context.Context, p peer.Peer,
}
}()
network
:=
bsnet
.
NewFromIpfsNetwork
(
srv
,
net
)
bs
:=
&
bitswap
{
blockstore
:
blockstore
.
NewBlockstore
(
d
),
notifications
:
notif
,
...
...
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