Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion accounts/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,19 @@ func (ks *KeyStore) Subscribe(sink chan<- accounts.WalletEvent) event.Subscripti
// forces a manual refresh (only triggers for systems where the filesystem notifier
// is not running).
func (ks *KeyStore) updater() {
// Create a timer for the wallet refresh cycle
timer := time.NewTimer(walletRefreshCycle)
defer timer.Stop()

for {
// Wait for an account update or a refresh timeout
select {
case <-ks.changes:
case <-time.After(walletRefreshCycle):
// Stop the timer if we receive an account update before the timer fires
if !timer.Stop() {
<-timer.C
}
case <-timer.C:
}
// Run the wallet refresher
ks.refreshWallets()
Expand All @@ -215,6 +223,9 @@ func (ks *KeyStore) updater() {
return
}
ks.mu.Unlock()

// Reset the timer for the next cycle
timer.Reset(walletRefreshCycle)
}
}

Expand Down
4 changes: 3 additions & 1 deletion consensus/XDPoS/engines/engine_v2/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,10 @@ func (x *XDPoS_v2) allowedToSend(chain consensus.ChainReader, blockHeader *types
// Periodlly execution(Attached to engine initialisation during "new"). Used for pool cleaning etc
func (x *XDPoS_v2) periodicJob() {
go func() {
ticker := time.NewTicker(utils.PeriodicJobPeriod * time.Second)
defer ticker.Stop()
for {
<-time.After(utils.PeriodicJobPeriod * time.Second)
<-ticker.C
x.hygieneVotePool()
x.hygieneTimeoutPool()
}
Expand Down
6 changes: 5 additions & 1 deletion consensus/ethash/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
defer close(done)

go func() {
waitDuration := 3 * time.Second
timer := time.NewTimer(waitDuration)
defer timer.Stop()
for {
select {
case <-done:
return
case <-time.After(3 * time.Second):
case <-timer.C:
logger.Info("Generating ethash verification cache", "percentage", atomic.LoadUint32(&progress)*100/uint32(rows)/4, "elapsed", common.PrettyDuration(time.Since(start)))
timer.Reset(waitDuration)
}
}
}()
Expand Down
5 changes: 4 additions & 1 deletion core/bloombits/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ func (s *MatcherSession) DeliverSections(bit uint, sections []uint64, bitsets []
// of the session, any request in-flight need to be responded to! Empty responses
// are fine though in that case.
func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan *Retrieval) {
ticker := time.NewTicker(wait)
defer ticker.Stop()

for {
// Allocate a new bloom bit index to retrieve data for, stopping when done
bit, ok := s.AllocateRetrieval()
Expand All @@ -621,7 +624,7 @@ func (s *MatcherSession) Multiplex(batch int, wait time.Duration, mux chan chan
s.DeliverSections(bit, []uint64{}, [][]byte{})
return

case <-time.After(wait):
case <-ticker.C:
// Throttling up, fetch whatever's available
}
}
Expand Down