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-unixfs
Commits
20802018
Commit
20802018
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bit swap) stub out a concrete strategist
parent
22539cf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
bitswap/strategy/strategy.go
bitswap/strategy/strategy.go
+58
-0
No files found.
bitswap/strategy/strategy.go
0 → 100644
View file @
20802018
package
strategy
import
(
"errors"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
bsmsg
"github.com/jbenet/go-ipfs/bitswap/message"
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
)
// TODO declare thread-safe datastore
func
New
(
d
ds
.
Datastore
)
Strategist
{
return
&
strategist
{
datastore
:
d
,
peers
:
ledgerMap
{},
}
}
type
strategist
struct
{
datastore
ds
.
Datastore
// FIXME(brian): enforce thread-safe datastore
peers
ledgerMap
}
// Peers returns a list of this instance is connected to
func
(
s
*
strategist
)
Peers
()
[]
*
peer
.
Peer
{
response
:=
make
([]
*
peer
.
Peer
,
0
)
// TODO
return
response
}
func
(
s
*
strategist
)
IsWantedByPeer
(
u
.
Key
,
*
peer
.
Peer
)
bool
{
return
true
// TODO
}
func
(
s
*
strategist
)
ShouldSendToPeer
(
u
.
Key
,
*
peer
.
Peer
)
bool
{
return
true
// TODO
}
func
(
s
*
strategist
)
Seed
(
int64
)
{
// TODO
}
func
(
s
*
strategist
)
MessageReceived
(
*
peer
.
Peer
,
bsmsg
.
BitSwapMessage
)
error
{
// TODO add peer to partners if doesn't already exist.
// TODO initialize ledger for peer if doesn't already exist
// TODO get wantlist from message and update contents in local wantlist for peer
// TODO acknowledge receipt of blocks and do accounting in ledger
return
errors
.
New
(
"TODO"
)
}
func
(
s
*
strategist
)
MessageSent
(
*
peer
.
Peer
,
bsmsg
.
BitSwapMessage
)
error
{
// TODO add peer to partners if doesn't already exist.
// TODO initialize ledger for peer if doesn't already exist
// TODO add block to my wantlist
// TODO acknowledge receipt of blocks and do accounting in ledger
return
errors
.
New
(
"TODO"
)
}
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