Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
49bcb5fb
Unverified
Commit
49bcb5fb
authored
Mar 02, 2018
by
Péter Szilágyi
Committed by
GitHub
Mar 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16228 from karalabe/faucet-background-skip
cmd/faucet: update state in background, skip when busy
parents
d520bf45
6f13e515
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
faucet.go
cmd/faucet/faucet.go
+16
-3
No files found.
cmd/faucet/faucet.go
View file @
49bcb5fb
...
@@ -533,9 +533,11 @@ func (f *faucet) loop() {
...
@@ -533,9 +533,11 @@ func (f *faucet) loop() {
}
}
defer
sub
.
Unsubscribe
()
defer
sub
.
Unsubscribe
()
for
{
// Start a goroutine to update the state from head notifications in the background
select
{
update
:=
make
(
chan
*
types
.
Header
)
case
head
:=
<-
heads
:
go
func
()
{
for
head
:=
range
update
{
// New chain head arrived, query the current stats and stream to clients
// New chain head arrived, query the current stats and stream to clients
var
(
var
(
balance
*
big
.
Int
balance
*
big
.
Int
...
@@ -588,6 +590,17 @@ func (f *faucet) loop() {
...
@@ -588,6 +590,17 @@ func (f *faucet) loop() {
}
}
}
}
f
.
lock
.
RUnlock
()
f
.
lock
.
RUnlock
()
}
}()
// Wait for various events and assing to the appropriate background threads
for
{
select
{
case
head
:=
<-
heads
:
// New head arrived, send if for state update if there's none running
select
{
case
update
<-
head
:
default
:
}
case
<-
f
.
update
:
case
<-
f
.
update
:
// Pending requests updated, stream to clients
// Pending requests updated, stream to clients
...
...
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