@@ -93,7 +93,7 @@ func (status StatusReport) TimeSinceLastRound() time.Duration {
93
93
94
94
// AlgorandFullNode specifies and implements a full Algorand node.
95
95
type AlgorandFullNode struct {
96
- mu deadlock.RWMutex
96
+ mu deadlock.Mutex
97
97
ctx context.Context
98
98
cancelCtx context.CancelFunc
99
99
config config.Local
@@ -407,11 +407,11 @@ func (node *AlgorandFullNode) startMonitoringRoutines() {
407
407
408
408
// PKI TODO: Remove this with #2596
409
409
// Periodically check for new participation keys
410
- go node .checkForParticipationKeys ()
410
+ go node .checkForParticipationKeys (node . ctx . Done () )
411
411
412
- go node .txPoolGaugeThread ()
412
+ go node .txPoolGaugeThread (node . ctx . Done () )
413
413
// Delete old participation keys
414
- go node .oldKeyDeletionThread ()
414
+ go node .oldKeyDeletionThread (node . ctx . Done () )
415
415
416
416
// TODO re-enable with configuration flag post V1
417
417
//go logging.UsageLogThread(node.ctx, node.log, 100*time.Millisecond, nil)
@@ -782,7 +782,7 @@ func ensureParticipationDB(genesisDir string, log logging.Logger) (account.Parti
782
782
}
783
783
784
784
// Reload participation keys from disk periodically
785
- func (node * AlgorandFullNode ) checkForParticipationKeys () {
785
+ func (node * AlgorandFullNode ) checkForParticipationKeys (done <- chan struct {} ) {
786
786
defer node .monitoringRoutinesWaitGroup .Done ()
787
787
ticker := time .NewTicker (node .config .ParticipationKeysRefreshInterval )
788
788
for {
@@ -792,7 +792,7 @@ func (node *AlgorandFullNode) checkForParticipationKeys() {
792
792
if err != nil {
793
793
node .log .Errorf ("Could not refresh participation keys: %v" , err )
794
794
}
795
- case <- node . ctx . Done () :
795
+ case <- done :
796
796
ticker .Stop ()
797
797
return
798
798
}
@@ -1032,14 +1032,11 @@ func insertStateProofToRegistry(part account.PersistedParticipation, node *Algor
1032
1032
1033
1033
var txPoolGuage = metrics .MakeGauge (metrics.MetricName {Name : "algod_tx_pool_count" , Description : "current number of available transactions in pool" })
1034
1034
1035
- func (node * AlgorandFullNode ) txPoolGaugeThread () {
1035
+ func (node * AlgorandFullNode ) txPoolGaugeThread (done <- chan struct {} ) {
1036
1036
defer node .monitoringRoutinesWaitGroup .Done ()
1037
1037
ticker := time .NewTicker (10 * time .Second )
1038
1038
defer ticker .Stop ()
1039
1039
for true {
1040
- node .mu .RLock ()
1041
- done := node .ctx .Done ()
1042
- node .mu .RUnlock ()
1043
1040
select {
1044
1041
case <- ticker .C :
1045
1042
txPoolGuage .Set (float64 (node .transactionPool .PendingCount ()), nil )
@@ -1074,12 +1071,9 @@ func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgerco
1074
1071
// oldKeyDeletionThread keeps deleting old participation keys.
1075
1072
// It runs in a separate thread so that, during catchup, we
1076
1073
// don't have to delete key for each block we received.
1077
- func (node * AlgorandFullNode ) oldKeyDeletionThread () {
1074
+ func (node * AlgorandFullNode ) oldKeyDeletionThread (done <- chan struct {} ) {
1078
1075
defer node .monitoringRoutinesWaitGroup .Done ()
1079
1076
for {
1080
- node .mu .RLock ()
1081
- done := node .ctx .Done ()
1082
- node .mu .RUnlock ()
1083
1077
select {
1084
1078
case <- done :
1085
1079
return
0 commit comments