File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -533,9 +533,11 @@ func (f *faucet) loop() {
533
533
}
534
534
defer sub .Unsubscribe ()
535
535
536
- for {
537
- select {
538
- case head := <- heads :
536
+ // Start a goroutine to update the state from head notifications in the background
537
+ update := make (chan * types.Header )
538
+
539
+ go func () {
540
+ for head := range update {
539
541
// New chain head arrived, query the current stats and stream to clients
540
542
var (
541
543
balance * big.Int
@@ -588,6 +590,17 @@ func (f *faucet) loop() {
588
590
}
589
591
}
590
592
f .lock .RUnlock ()
593
+ }
594
+ }()
595
+ // Wait for various events and assing to the appropriate background threads
596
+ for {
597
+ select {
598
+ case head := <- heads :
599
+ // New head arrived, send if for state update if there's none running
600
+ select {
601
+ case update <- head :
602
+ default :
603
+ }
591
604
592
605
case <- f .update :
593
606
// Pending requests updated, stream to clients
You can’t perform that action at this time.
0 commit comments