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
9c4e6703
Commit
9c4e6703
authored
Aug 16, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint fixes
parent
0c1a2027
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
bitswap/bitswap.go
bitswap/bitswap.go
+13
-9
No files found.
bitswap/bitswap.go
View file @
9c4e6703
package
bitswap
import
(
blocks
"github.com/jbenet/go-ipfs/blocks"
peer
"github.com/jbenet/go-ipfs/peer"
swarm
"github.com/jbenet/go-ipfs/swarm"
u
"github.com/jbenet/go-ipfs/util"
ds
"github.com/jbenet/datastore.go"
...
...
@@ -32,7 +34,7 @@ type Ledger struct {
BytesReceived
uint64
// FirstExchnage is the time of the first data exchange.
La
stExchange
*
time
.
Time
Fir
stExchange
*
time
.
Time
// LastExchange is the time of the last data exchange.
LastExchange
*
time
.
Time
...
...
@@ -44,9 +46,10 @@ type Ledger struct {
// LedgerMap lists Ledgers by their Partner key.
type
LedgerMap
map
[
u
.
Key
]
*
Ledger
// BitSwap instances implement the bitswap protocol.
type
BitSwap
struct
{
// peer is the identity of this (local) node.
peer
peer
.
Peer
peer
*
peer
.
Peer
// net holds the connections to all peers.
net
swarm
.
Network
...
...
@@ -68,24 +71,25 @@ type BitSwap struct {
wantList
KeySet
}
// NewBitSwap creates a new BitSwap instance. It does not check its parameters.
func
NewBitSwap
(
p
*
peer
.
Peer
,
net
swarm
.
Network
,
d
ds
.
Datastore
)
*
BitSwap
{
return
&
BitSwap
{
peer
:
p
,
net
:
net
,
datastore
:
d
,
ledgers
:
&
LedgerMap
{},
haveList
:
&
KeySet
{},
wantList
:
&
KeySet
{},
partners
:
LedgerMap
{},
wantList
:
KeySet
{},
}
}
// GetBlock attempts to retrieve a particular block from peers, within timeout.
func
(
s
*
BitSwap
)
GetBlock
(
k
u
.
Key
,
timeout
time
.
Time
)
(
*
Block
,
error
)
{
func
(
s
*
BitSwap
)
GetBlock
(
k
u
.
Key
,
timeout
time
.
Time
)
(
*
blocks
.
Block
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
//
A
nnounce the existance of a block to BitSwap, potentially sending
it to
// peers (Partners) whose WantLists include it.
func
(
s
*
BitSwap
)
HaveBlock
(
k
u
.
Key
)
(
*
Block
,
error
)
{
//
HaveBlock a
nnounce
s
the existance of a block to BitSwap, potentially sending
//
it to
peers (Partners) whose WantLists include it.
func
(
s
*
BitSwap
)
HaveBlock
(
k
u
.
Key
)
(
*
blocks
.
Block
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
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