aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus.go
diff options
context:
space:
mode:
authorhaoping-ku <haoping.ku@dexon.org>2018-12-05 17:38:03 +0800
committerGitHub <noreply@github.com>2018-12-05 17:38:03 +0800
commit4eb02f1dd96e136b0f7cf7eff792da1e44176713 (patch)
tree3757739bff31ce4b9cb7ff45be572f9858fc19e9 /core/consensus.go
parent1f48b590f6e9a6d3fd773846a3d8ba1b7f0419e6 (diff)
downloadtangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar.gz
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar.bz2
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar.lz
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar.xz
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.tar.zst
tangerine-consensus-4eb02f1dd96e136b0f7cf7eff792da1e44176713.zip
Haoping fix simulation (#356)
* simulation: add benchmark features * tmp * simulation: modify Debug interface * Added BlockReceived and BlockReady function to Debug interface. * Added Benchmark features. * fix * fix typos
Diffstat (limited to 'core/consensus.go')
-rw-r--r--core/consensus.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/consensus.go b/core/consensus.go
index bfe893c..6ca54e0 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -340,10 +340,11 @@ type Consensus struct {
toSyncer *totalOrderingSyncer
// Interfaces.
- db blockdb.BlockDatabase
- app Application
- gov Governance
- network Network
+ db blockdb.BlockDatabase
+ app Application
+ debugApp Debug
+ gov Governance
+ network Network
// Misc.
dMoment time.Time
@@ -372,7 +373,10 @@ func NewConsensus(
// Setup auth module.
authModule := NewAuthenticator(prv)
// Check if the application implement Debug interface.
- debugApp, _ := app.(Debug)
+ var debugApp Debug
+ if a, ok := app.(Debug); ok {
+ debugApp = a
+ }
// Get configuration for genesis round.
var round uint64
logger.Debug("Calling Governance.Configuration", "round", round)
@@ -407,6 +411,7 @@ func NewConsensus(
ccModule: newCompactionChain(gov),
lattice: lattice,
app: newNonBlocking(app, debugApp),
+ debugApp: debugApp,
gov: gov,
db: db,
network: network,
@@ -961,6 +966,9 @@ func (con *Consensus) ProcessBlockRandomnessResult(
// preProcessBlock performs Byzantine Agreement on the block.
func (con *Consensus) preProcessBlock(b *types.Block) (err error) {
err = con.baMgr.processBlock(b)
+ if err == nil && con.debugApp != nil {
+ con.debugApp.BlockReceived(b.Hash)
+ }
return
}
@@ -1027,6 +1035,9 @@ func (con *Consensus) processBlock(block *types.Block) (err error) {
}
con.cfgModule.untouchTSigHash(b.Hash)
con.deliverBlock(b)
+ if con.debugApp != nil {
+ con.debugApp.BlockReady(b.Hash)
+ }
}
if err = con.lattice.PurgeBlocks(deliveredBlocks); err != nil {
return