diff options
author | wmin0 <wmin0@hotmail.com> | 2019-01-04 16:28:47 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-01-04 16:28:47 +0800 |
commit | 17b96ca95ffd4cbf8af762a974fc8b18f2c1b993 (patch) | |
tree | 10df60f30c05b731e81755cfd3e4e57625b1630b /core/syncer/consensus.go | |
parent | beaef47dd5dd4b342cef3c8b26508ce3c334be06 (diff) | |
download | dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar.gz dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar.bz2 dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar.lz dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar.xz dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.tar.zst dexon-consensus-17b96ca95ffd4cbf8af762a974fc8b18f2c1b993.zip |
core: syncer: safe spawn go routine (#399)
Diffstat (limited to 'core/syncer/consensus.go')
-rw-r--r-- | core/syncer/consensus.go | 9 |
1 files changed, 6 insertions, 3 deletions
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() + }() } } } |