aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
diff options
context:
space:
mode:
authorBJ4 <bojie@dexon.org>2018-11-02 18:09:57 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commit5bd42d357da00298fa47bd8c672721195cf61d9a (patch)
treede53593d22ea0cb9d4391b4284024560bf7f4497 /vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
parent00f2c4e5a65533dd3e2cd726ee55f90c477ad6c3 (diff)
downloadgo-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.gz
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.bz2
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.lz
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.xz
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.zst
go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.zip
app: lock by chain correctly and remove old core in vendor
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
index cec3c4f64..29d4aa2c8 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
@@ -315,12 +315,6 @@ func NewConsensus(
config := gov.Configuration(round)
nodeSetCache := NewNodeSetCache(gov)
logger.Debug("Calling Governance.CRS", "round", round)
- crs := gov.CRS(round)
- // Setup acking by information returned from Governace.
- nodes, err := nodeSetCache.GetNodeSet(round)
- if err != nil {
- panic(err)
- }
// Setup auth module.
authModule := NewAuthenticator(prv)
// Check if the application implement Debug interface.
@@ -385,8 +379,7 @@ func NewConsensus(
agreementModule := newAgreement(
con.ID,
recv,
- nodes.IDs,
- newLeaderSelector(crs, validLeader),
+ newLeaderSelector(validLeader),
con.authModule,
)
// Hacky way to make agreement module self contained.
@@ -448,6 +441,7 @@ func (con *Consensus) runBA(chainID uint32, tick <-chan struct{}) {
recv := con.receivers[chainID]
recv.restartNotary <- true
nIDs := make(map[types.NodeID]struct{})
+ crs := common.Hash{}
// Reset ticker
<-tick
BALoop:
@@ -466,16 +460,17 @@ BALoop:
if err != nil {
panic(err)
}
+ con.logger.Debug("Calling Governance.CRS", "round", recv.round)
+ crs = con.gov.CRS(recv.round)
con.logger.Debug("Calling Governance.Configuration",
"round", recv.round)
- con.logger.Debug("Calling Governance.CRS", "round", recv.round)
nIDs = nodes.GetSubSet(
int(con.gov.Configuration(recv.round).NotarySetSize),
- types.NewNotarySetTarget(con.gov.CRS(recv.round), chainID))
+ types.NewNotarySetTarget(crs, chainID))
}
nextPos := con.lattice.NextPosition(chainID)
nextPos.Round = recv.round
- agreement.restart(nIDs, nextPos)
+ agreement.restart(nIDs, nextPos, crs)
default:
}
if agreement.pullVotes() {
@@ -809,14 +804,15 @@ func (con *Consensus) ProcessAgreementResult(
con.logger.Debug("Calling Network.PullBlocks for syncing BA",
"hash", rand.BlockHash)
con.network.PullBlocks(common.Hashes{rand.BlockHash})
+ con.logger.Debug("Calling Governance.CRS", "round", rand.Position.Round)
+ crs := con.gov.CRS(rand.Position.Round)
nIDs := nodes.GetSubSet(
int(con.gov.Configuration(rand.Position.Round).NotarySetSize),
- types.NewNotarySetTarget(
- con.gov.CRS(rand.Position.Round), rand.Position.ChainID))
+ types.NewNotarySetTarget(crs, rand.Position.ChainID))
for _, vote := range rand.Votes {
agreement.processVote(&vote)
}
- agreement.restart(nIDs, rand.Position)
+ agreement.restart(nIDs, rand.Position, crs)
}
// Calculating randomness.
if rand.Position.Round == 0 {
@@ -929,7 +925,7 @@ func (con *Consensus) preProcessBlock(b *types.Block) (err error) {
func (con *Consensus) deliverBlock(b *types.Block) {
// TODO(mission): clone types.FinalizationResult
con.logger.Debug("Calling Application.BlockDelivered", "block", b)
- con.app.BlockDelivered(b.Hash, b.Finalization)
+ con.app.BlockDelivered(b.Hash, b.Position, b.Finalization)
if b.Position.Round+2 == con.roundToNotify {
// Only the first block delivered of that round would
// trigger this noitification.