aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-01-04 23:59:17 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:21 +0800
commitf2865a49b3a18f7d02886a831a14d99033bf43ae (patch)
treed6f3d8fab446222fe3d5f4d3bea557a9f279ee30 /vendor/github.com/dexon-foundation/dexon-consensus/core/syncer
parent30950e88c8c96b583b34da0a8ec1e2b44b4e1b0b (diff)
downloadgo-tangerine-f2865a49b3a18f7d02886a831a14d99033bf43ae.tar.gz
go-tangerine-f2865a49b3a18f7d02886a831a14d99033bf43ae.tar.zst
go-tangerine-f2865a49b3a18f7d02886a831a14d99033bf43ae.zip
vendor: sync to latest core (#129)
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/syncer')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go11
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go19
2 files changed, 13 insertions, 17 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go
index 32ea6547a..9b351eabc 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/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:
@@ -106,7 +99,7 @@ func (a *agreement) processBlock(b *types.Block) {
func (a *agreement) processAgreementResult(r *types.AgreementResult) {
// Cache those results that CRS is not ready yet.
if _, exists := a.confirmedBlocks[r.BlockHash]; exists {
- a.logger.Debug("agreement result already confirmed", "result", r)
+ a.logger.Trace("agreement result already confirmed", "result", r)
return
}
if r.Position.Round > a.latestCRSRound {
@@ -116,7 +109,7 @@ func (a *agreement) processAgreementResult(r *types.AgreementResult) {
a.pendings[r.Position.Round] = pendingsForRound
}
pendingsForRound[r.BlockHash] = r
- a.logger.Debug("agreement result cached", "result", r)
+ a.logger.Trace("agreement result cached", "result", r)
return
}
if err := core.VerifyAgreementResult(r, a.cache); err != nil {
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
index d334bbd88..92f8fd8d0 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
@@ -262,12 +262,12 @@ func (con *Consensus) ensureAgreementOverlapRound() bool {
for r = range tipRoundMap {
break
}
- con.logger.Info("check agreement round cut",
+ con.logger.Debug("check agreement round cut",
"tip-round", r,
"configs", len(con.configs))
if tipRoundMap[r] == con.configs[r].NumChains {
con.agreementRoundCut = r
- con.logger.Debug("agreement round cut found, round", r)
+ con.logger.Info("agreement round cut found, round", r)
return true
}
}
@@ -416,7 +416,7 @@ func (con *Consensus) SyncBlocks(
"expected", tipHeight+1)
return false, ErrInvalidSyncingFinalizationHeight
}
- con.logger.Debug("syncBlocks",
+ con.logger.Trace("syncBlocks",
"position", &blocks[0].Position,
"final height", blocks[0].Finalization.Height,
"len", len(blocks),
@@ -601,7 +601,7 @@ func (con *Consensus) setupConfigs(blocks []*types.Block) {
maxRound = b.Position.Round
}
}
- con.logger.Info("syncer setupConfigs",
+ con.logger.Debug("syncer setupConfigs",
"max", maxRound,
"lattice", con.latticeLastRound)
// Get configs from governance.
@@ -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()
+ }()
}
}
}
@@ -734,7 +737,7 @@ func (con *Consensus) startCRSMonitor() {
if round == lastNotifiedRound {
return
}
- con.logger.Info("CRS is ready", "round", round)
+ con.logger.Debug("CRS is ready", "round", round)
lastNotifiedRound = round
for _, a := range con.agreements {
a.inputChan <- round