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
90fede8d
Commit
90fede8d
authored
Apr 28, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let wantlist command show other peers wantlists
parent
70f2b6b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
bitswap.go
bitswap.go
+8
-0
decision/engine.go
decision/engine.go
+10
-0
No files found.
bitswap.go
View file @
90fede8d
...
@@ -175,6 +175,14 @@ func (bs *Bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
...
@@ -175,6 +175,14 @@ func (bs *Bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
}
}
}
}
func
(
bs
*
Bitswap
)
WantlistForPeer
(
p
peer
.
ID
)
[]
u
.
Key
{
var
out
[]
u
.
Key
for
_
,
e
:=
range
bs
.
engine
.
WantlistForPeer
(
p
)
{
out
=
append
(
out
,
e
.
Key
)
}
return
out
}
// GetBlocks returns a channel where the caller may receive blocks that
// GetBlocks returns a channel where the caller may receive blocks that
// correspond to the provided |keys|. Returns an error if BitSwap is unable to
// correspond to the provided |keys|. Returns an error if BitSwap is unable to
// begin this request within the deadline enforced by the context.
// begin this request within the deadline enforced by the context.
...
...
decision/engine.go
View file @
90fede8d
...
@@ -96,6 +96,16 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine {
...
@@ -96,6 +96,16 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine {
return
e
return
e
}
}
func
(
e
*
Engine
)
WantlistForPeer
(
p
peer
.
ID
)
(
out
[]
wl
.
Entry
)
{
e
.
lock
.
Lock
()
partner
,
ok
:=
e
.
ledgerMap
[
p
]
if
ok
{
out
=
partner
.
wantList
.
SortedEntries
()
}
e
.
lock
.
Unlock
()
return
out
}
func
(
e
*
Engine
)
taskWorker
(
ctx
context
.
Context
)
{
func
(
e
*
Engine
)
taskWorker
(
ctx
context
.
Context
)
{
defer
close
(
e
.
outbox
)
// because taskWorker uses the channel exclusively
defer
close
(
e
.
outbox
)
// because taskWorker uses the channel exclusively
for
{
for
{
...
...
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