diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-12-04 10:10:17 +0800 |
---|---|---|
committer | Mission Liao <mission.liao@dexon.org> | 2018-12-04 10:10:17 +0800 |
commit | 0be7c830e4f96a7ae1a957c4bb12772447617076 (patch) | |
tree | 3cadafadf998446a01a322230c41c9d2f7527a5b | |
parent | 041eb53f043e6a4a7a9acab1ce46ecfd268fed57 (diff) | |
download | tangerine-consensus-0be7c830e4f96a7ae1a957c4bb12772447617076.tar.gz tangerine-consensus-0be7c830e4f96a7ae1a957c4bb12772447617076.tar.zst tangerine-consensus-0be7c830e4f96a7ae1a957c4bb12772447617076.zip |
core: Fix stuffs (#354)
- Add common.CustomLogger
- CRS will wait for DKG to finish
- Fix core.agreementMgr.processAgreementResult
-rw-r--r-- | common/logger.go | 32 | ||||
-rw-r--r-- | core/agreement-mgr.go | 4 | ||||
-rw-r--r-- | core/consensus.go | 9 |
3 files changed, 43 insertions, 2 deletions
diff --git a/common/logger.go b/common/logger.go index 2eb1e2b..29eac35 100644 --- a/common/logger.go +++ b/common/logger.go @@ -85,3 +85,35 @@ func (logger *SimpleLogger) Warn(msg string, ctx ...interface{}) { func (logger *SimpleLogger) Error(msg string, ctx ...interface{}) { log.Println(composeVargs(msg, ctx)...) } + +// CustomLogger logs everything. +type CustomLogger struct { + logger *log.Logger +} + +// NewCustomLogger creates a new custom logger. +func NewCustomLogger(logger *log.Logger) *CustomLogger { + return &CustomLogger{ + logger: logger, + } +} + +// Debug implements Logger interface. +func (logger *CustomLogger) Debug(msg string, ctx ...interface{}) { + logger.logger.Println(composeVargs(msg, ctx)...) +} + +// Info implements Logger interface. +func (logger *CustomLogger) Info(msg string, ctx ...interface{}) { + logger.logger.Println(composeVargs(msg, ctx)...) +} + +// Warn implements Logger interface. +func (logger *CustomLogger) Warn(msg string, ctx ...interface{}) { + logger.logger.Println(composeVargs(msg, ctx)...) +} + +// Error implements Logger interface. +func (logger *CustomLogger) Error(msg string, ctx ...interface{}) { + logger.logger.Println(composeVargs(msg, ctx)...) +} diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go index cbce6d2..57fb5c5 100644 --- a/core/agreement-mgr.go +++ b/core/agreement-mgr.go @@ -251,8 +251,8 @@ func (mgr *agreementMgr) processAgreementResult( nIDs := nodes.GetSubSet( int(mgr.gov.Configuration(result.Position.Round).NotarySetSize), types.NewNotarySetTarget(crs, result.Position.ChainID)) - for _, vote := range result.Votes { - agreement.processVote(&vote) + for key := range result.Votes { + agreement.processVote(&result.Votes[key]) } agreement.restart(nIDs, result.Position, crs) } diff --git a/core/consensus.go b/core/consensus.go index efd3ab7..a1aa072 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -611,6 +611,15 @@ func (con *Consensus) runCRS(round uint64) { con.logger.Info("CRS already proposed", "round", round+1) return } + con.logger.Debug("Calling Governance.IsDKGFinal to check if ready to run CRS", + "round", round) + for !con.gov.IsDKGFinal(round) { + con.logger.Debug("DKG is not ready for running CRS. Retry later...", + "round", round) + time.Sleep(500 * time.Millisecond) + } + // Wait some time for DKG to recover private share. + time.Sleep(100 * time.Millisecond) // Start running next round CRS. con.logger.Debug("Calling Governance.CRS", "round", round) psig, err := con.cfgModule.preparePartialSignature(round, con.gov.CRS(round)) |