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
574213ff
Commit
574213ff
authored
Dec 17, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(bs/decision.Engine): pass in Entry
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
fa030d66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
decision/engine.go
decision/engine.go
+2
-2
decision/taskqueue.go
decision/taskqueue.go
+5
-8
No files found.
decision/engine.go
View file @
574213ff
...
...
@@ -129,7 +129,7 @@ func (e *Engine) MessageReceived(p peer.Peer, m bsmsg.BitSwapMessage) error {
l
.
Wants
(
entry
.
Key
,
entry
.
Priority
)
if
exists
,
err
:=
e
.
bs
.
Has
(
entry
.
Key
);
err
==
nil
&&
exists
{
newWorkExists
=
true
e
.
peerRequestQueue
.
Push
(
entry
.
Key
,
entry
.
Priorit
y
,
p
)
e
.
peerRequestQueue
.
Push
(
entry
.
Entr
y
,
p
)
}
}
}
...
...
@@ -140,7 +140,7 @@ func (e *Engine) MessageReceived(p peer.Peer, m bsmsg.BitSwapMessage) error {
for
_
,
l
:=
range
e
.
ledgerMap
{
if
l
.
WantListContains
(
block
.
Key
())
{
newWorkExists
=
true
e
.
peerRequestQueue
.
Push
(
block
.
Key
(),
1
,
l
.
Partner
)
e
.
peerRequestQueue
.
Push
(
wl
.
Entry
{
block
.
Key
(),
1
}
,
l
.
Partner
)
}
}
}
...
...
decision/taskqueue.go
View file @
574213ff
...
...
@@ -28,22 +28,19 @@ type task struct {
}
// Push currently adds a new task to the end of the list
func
(
tl
*
taskQueue
)
Push
(
block
u
.
Key
,
priority
int
,
to
peer
.
Peer
)
{
if
task
,
ok
:=
tl
.
taskmap
[
taskKey
(
to
,
block
)];
ok
{
func
(
tl
*
taskQueue
)
Push
(
entry
wantlist
.
Entry
,
to
peer
.
Peer
)
{
if
task
,
ok
:=
tl
.
taskmap
[
taskKey
(
to
,
entry
.
Key
)];
ok
{
// TODO: when priority queue is implemented,
// rearrange this task
task
.
Entry
.
Priority
=
p
riority
task
.
Entry
.
Priority
=
entry
.
P
riority
return
}
task
:=
&
task
{
Entry
:
wantlist
.
Entry
{
Key
:
block
,
Priority
:
priority
,
},
Entry
:
entry
,
Target
:
to
,
}
tl
.
tasks
=
append
(
tl
.
tasks
,
task
)
tl
.
taskmap
[
taskKey
(
to
,
block
)]
=
task
tl
.
taskmap
[
taskKey
(
to
,
entry
.
Key
)]
=
task
}
// Pop 'pops' the next task to be performed. Returns nil no task exists.
...
...
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