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
44484941
Commit
44484941
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bitswap:strategy) add interfaces
refac(bitswap:strategy) update interface
parent
cff3a866
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
bitswap/strategy/interface.go
bitswap/strategy/interface.go
+49
-0
No files found.
bitswap/strategy/interface.go
0 → 100644
View file @
44484941
package
strategy
import
(
bsmsg
"github.com/jbenet/go-ipfs/bitswap/message"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
)
type
Strategist
interface
{
Accountant
// Returns a slice of Peers that
Peers
()
[]
*
peer
.
Peer
// WantList returns the WantList for the given Peer
IsWantedByPeer
(
u
.
Key
,
*
peer
.
Peer
)
bool
// ShouldSendTo(Peer) decides whether to send data to this Peer
ShouldSendToPeer
(
u
.
Key
,
*
peer
.
Peer
)
bool
// Seed initializes the decider to a deterministic state
Seed
(
int64
)
}
type
Accountant
interface
{
// MessageReceived records receipt of message for accounting purposes
MessageReceived
(
*
peer
.
Peer
,
bsmsg
.
BitSwapMessage
)
error
// MessageSent records sending of message for accounting purposes
MessageSent
(
*
peer
.
Peer
,
bsmsg
.
BitSwapMessage
)
error
}
type
WantList
interface
{
// Peer returns the owner of the WantList
Peer
()
*
peer
.
Peer
// Intersection returns the keys common to both WantLists
Intersection
(
WantList
)
WantList
KeySet
}
// TODO(brian): potentially move this somewhere more generic. For now, it's
// useful in BitSwap operations.
type
KeySet
interface
{
Contains
(
u
.
Key
)
bool
Keys
()
[]
u
.
Key
}
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