Skip to content

Commit

Permalink
pass the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed May 5, 2022
1 parent 7bbf404 commit 7878d41
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,15 @@ func (node *AlgorandFullNode) Start() {
func (node *AlgorandFullNode) startMonitoringRoutines() {
node.monitoringRoutinesWaitGroup.Add(3)

doneCh := node.ctx.Done()

// PKI TODO: Remove this with #2596
// Periodically check for new participation keys
go node.checkForParticipationKeys()
go node.checkForParticipationKeys(doneCh)

go node.txPoolGaugeThread()
go node.txPoolGaugeThread(doneCh)
// Delete old participation keys
go node.oldKeyDeletionThread()
go node.oldKeyDeletionThread(doneCh)

// TODO re-enable with configuration flag post V1
//go logging.UsageLogThread(node.ctx, node.log, 100*time.Millisecond, nil)
Expand Down Expand Up @@ -782,11 +784,8 @@ func ensureParticipationDB(genesisDir string, log logging.Logger) (account.Parti
}

// Reload participation keys from disk periodically
func (node *AlgorandFullNode) checkForParticipationKeys() {
func (node *AlgorandFullNode) checkForParticipationKeys(done <-chan struct{}) {
defer node.monitoringRoutinesWaitGroup.Done()
node.mu.RLock()
done := node.ctx.Done()
node.mu.RUnlock()
ticker := time.NewTicker(node.config.ParticipationKeysRefreshInterval)
defer ticker.Stop()
for {
Expand Down Expand Up @@ -1035,11 +1034,8 @@ func insertStateProofToRegistry(part account.PersistedParticipation, node *Algor

var txPoolGuage = metrics.MakeGauge(metrics.MetricName{Name: "algod_tx_pool_count", Description: "current number of available transactions in pool"})

func (node *AlgorandFullNode) txPoolGaugeThread() {
func (node *AlgorandFullNode) txPoolGaugeThread(done <-chan struct{}) {
defer node.monitoringRoutinesWaitGroup.Done()
node.mu.RLock()
done := node.ctx.Done()
node.mu.RUnlock()
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for true {
Expand Down Expand Up @@ -1077,10 +1073,7 @@ func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgerco
// oldKeyDeletionThread keeps deleting old participation keys.
// It runs in a separate thread so that, during catchup, we
// don't have to delete key for each block we received.
func (node *AlgorandFullNode) oldKeyDeletionThread() {
node.mu.RLock()
done := node.ctx.Done()
node.mu.RUnlock()
func (node *AlgorandFullNode) oldKeyDeletionThread(done <-chan struct{}) {
defer node.monitoringRoutinesWaitGroup.Done()
for {
select {
Expand Down

0 comments on commit 7878d41

Please sign in to comment.