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-blockservice
Commits
4332ac4c
Commit
4332ac4c
authored
Jan 20, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use rate-limiter
@jbenet
parent
d630e983
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
worker/worker.go
worker/worker.go
+7
-3
No files found.
worker/worker.go
View file @
4332ac4c
...
...
@@ -8,6 +8,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
process
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
ratelimit
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
blocks
"github.com/jbenet/go-ipfs/blocks"
exchange
"github.com/jbenet/go-ipfs/exchange"
util
"github.com/jbenet/go-ipfs/util"
...
...
@@ -124,6 +125,7 @@ func (w *Worker) start(c Config) {
cancel
()
})
limiter
:=
ratelimit
.
NewRateLimiter
(
proc
,
c
.
NumWorkers
)
for
{
select
{
case
<-
proc
.
Closing
()
:
...
...
@@ -132,9 +134,11 @@ func (w *Worker) start(c Config) {
if
!
ok
{
return
}
if
err
:=
w
.
exchange
.
HasBlock
(
ctx
,
block
);
err
!=
nil
{
// TODO log event?
}
limiter
.
LimitedGo
(
func
(
proc
process
.
Process
)
{
if
err
:=
w
.
exchange
.
HasBlock
(
ctx
,
block
);
err
!=
nil
{
// TODO log event?
}
})
}
}
})
...
...
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