aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go
index 2b5c4bc51..e8cafbd68 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go
@@ -148,7 +148,11 @@ func (mgr *agreementMgr) run() {
}
mgr.isRunning = true
for i := uint32(0); i < uint32(len(mgr.baModules)); i++ {
- go mgr.runBA(mgr.initRound, i)
+ mgr.waitGroup.Add(1)
+ go func(idx uint32) {
+ defer mgr.waitGroup.Done()
+ mgr.runBA(mgr.initRound, idx)
+ }(i)
}
}
@@ -186,7 +190,11 @@ func (mgr *agreementMgr) appendConfig(
recv.agreementModule = agrModule
mgr.baModules = append(mgr.baModules, agrModule)
if mgr.isRunning {
- go mgr.runBA(round, i)
+ mgr.waitGroup.Add(1)
+ go func(idx uint32) {
+ defer mgr.waitGroup.Done()
+ mgr.runBA(round, idx)
+ }(i)
}
}
return nil
@@ -277,8 +285,6 @@ func (mgr *agreementMgr) stop() {
}
func (mgr *agreementMgr) runBA(initRound uint64, chainID uint32) {
- mgr.waitGroup.Add(1)
- defer mgr.waitGroup.Done()
// Acquire agreement module.
agr, recv := func() (*agreement, *consensusBAReceiver) {
mgr.lock.RLock()