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-bitswap
Commits
847826d9
Commit
847826d9
authored
Dec 23, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "bitswap: network interface changed"
This reverts commit bf88f1aec5e3d397f97d64de52b52686cc7a8c8f.
parent
c2186853
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
14 deletions
+11
-14
bitswap.go
bitswap.go
+5
-7
network/interface.go
network/interface.go
+1
-1
network/ipfs_impl.go
network/ipfs_impl.go
+2
-3
testnet/network.go
testnet/network.go
+3
-3
No files found.
bitswap.go
View file @
847826d9
...
...
@@ -176,16 +176,14 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf
message
.
AddEntry
(
wanted
.
Key
,
wanted
.
Priority
)
}
wg
:=
sync
.
WaitGroup
{}
for
pi
:=
range
peers
{
log
.
Debugf
(
"bitswap.sendWantListTo: %s %s"
,
pi
.
ID
,
pi
.
Addrs
)
log
.
Event
(
ctx
,
"PeerToQuery"
,
pi
.
ID
)
for
peerToQuery
:=
range
peers
{
log
.
Event
(
ctx
,
"PeerToQuery"
,
peerToQuery
.
ID
)
wg
.
Add
(
1
)
go
func
(
p
i
peer
.
PeerInfo
)
{
go
func
(
p
peer
.
ID
)
{
defer
wg
.
Done
()
p
:=
pi
.
ID
log
.
Event
(
ctx
,
"DialPeer"
,
p
)
err
:=
bs
.
sender
.
DialPeer
(
ctx
,
p
i
)
err
:=
bs
.
sender
.
DialPeer
(
ctx
,
p
)
if
err
!=
nil
{
log
.
Errorf
(
"Error sender.DialPeer(%s): %s"
,
p
,
err
)
return
...
...
@@ -200,7 +198,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf
// communication fails. May require slightly different API to
// get better guarantees. May need shared sequence numbers.
bs
.
engine
.
MessageSent
(
p
,
message
)
}(
p
i
)
}(
p
eerToQuery
.
ID
)
}
wg
.
Wait
()
return
nil
...
...
network/interface.go
View file @
847826d9
...
...
@@ -12,7 +12,7 @@ import (
type
BitSwapNetwork
interface
{
// DialPeer ensures there is a connection to peer.
DialPeer
(
context
.
Context
,
peer
.
PeerInfo
)
error
DialPeer
(
context
.
Context
,
peer
.
ID
)
error
// SendMessage sends a BitSwap message to a peer.
SendMessage
(
...
...
network/ipfs_impl.go
View file @
847826d9
...
...
@@ -53,9 +53,8 @@ func (bsnet *impl) handleNewStream(s inet.Stream) {
}
func
(
bsnet
*
impl
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
PeerInfo
)
error
{
bsnet
.
network
.
Peerstore
()
.
AddAddresses
(
p
.
ID
,
p
.
Addrs
)
return
bsnet
.
network
.
DialPeer
(
ctx
,
p
.
ID
)
func
(
bsnet
*
impl
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
ID
)
error
{
return
bsnet
.
network
.
DialPeer
(
ctx
,
p
)
}
func
(
bsnet
*
impl
)
SendMessage
(
...
...
testnet/network.go
View file @
847826d9
...
...
@@ -165,10 +165,10 @@ func (nc *networkClient) SendRequest(
return
nc
.
network
.
SendRequest
(
ctx
,
nc
.
local
,
to
,
message
)
}
func
(
nc
*
networkClient
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
PeerInfo
)
error
{
func
(
nc
*
networkClient
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
ID
)
error
{
// no need to do anything because dialing isn't a thing in this test net.
if
!
nc
.
network
.
HasPeer
(
p
.
ID
)
{
return
fmt
.
Errorf
(
"Peer not in network: %s"
,
p
.
ID
)
if
!
nc
.
network
.
HasPeer
(
p
)
{
return
fmt
.
Errorf
(
"Peer not in network: %s"
,
p
)
}
return
nil
}
...
...
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