aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/syncer/agreement.go7
-rw-r--r--core/syncer/consensus.go9
2 files changed, 6 insertions, 10 deletions
diff --git a/core/syncer/agreement.go b/core/syncer/agreement.go
index 32ea654..08be77a 100644
--- a/core/syncer/agreement.go
+++ b/core/syncer/agreement.go
@@ -18,8 +18,6 @@
package syncer
import (
- "sync"
-
"github.com/dexon-foundation/dexon-consensus/common"
"github.com/dexon-foundation/dexon-consensus/core"
"github.com/dexon-foundation/dexon-consensus/core/types"
@@ -29,7 +27,6 @@ import (
// Struct agreement implements struct of BA (Byzantine Agreement) protocol
// needed in syncer, which only receives agreement results.
type agreement struct {
- wg *sync.WaitGroup
cache *utils.NodeSetCache
inputChan chan interface{}
outputChan chan<- *types.Block
@@ -47,12 +44,10 @@ func newAgreement(
ch chan<- *types.Block,
pullChan chan<- common.Hash,
cache *utils.NodeSetCache,
- wg *sync.WaitGroup,
logger common.Logger) *agreement {
return &agreement{
cache: cache,
- wg: wg,
inputChan: make(chan interface{}, 1000),
outputChan: ch,
pullChan: pullChan,
@@ -68,8 +63,6 @@ func newAgreement(
// run starts the agreement, this does not start a new routine, go a new
// routine explicitly in the caller.
func (a *agreement) run() {
- a.wg.Add(1)
- defer a.wg.Done()
for {
select {
case val, ok := <-a.inputChan:
diff --git a/core/syncer/consensus.go b/core/syncer/consensus.go
index d334bbd..8852a47 100644
--- a/core/syncer/consensus.go
+++ b/core/syncer/consensus.go
@@ -623,10 +623,13 @@ func (con *Consensus) resizeByNumChains(numChains uint32) {
// Resize the pool of blocks.
con.blocks = append(con.blocks, types.ByPosition{})
// Resize agreement modules.
- a := newAgreement(con.receiveChan, con.pullChan, con.nodeSetCache,
- &con.agreementWaitGroup, con.logger)
+ a := newAgreement(con.receiveChan, con.pullChan, con.nodeSetCache, con.logger)
con.agreements = append(con.agreements, a)
- go a.run()
+ con.agreementWaitGroup.Add(1)
+ go func() {
+ defer con.agreementWaitGroup.Done()
+ a.run()
+ }()
}
}
}