aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-09-17 17:45:49 +0800
committerGitHub <noreply@github.com>2018-09-17 17:45:49 +0800
commit8a908e98279d7e80978cd412057eddd4a6bbf06c (patch)
tree4e28f76fd95814978210c6f38ec4a09988e76957 /core/consensus.go
parentcbf0012603deb6d2b8c257c079de98792f7b84cf (diff)
downloadtangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar.gz
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar.bz2
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar.lz
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar.xz
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.tar.zst
tangerine-consensus-8a908e98279d7e80978cd412057eddd4a6bbf06c.zip
core: move blockdb into core package and minor change on governance interface (#110)
Since third party apps will possibly implement their only blockdb class, it make sense for the interface to be in core. Also add GetNumShards into the governance interface.
Diffstat (limited to 'core/consensus.go')
-rw-r--r--core/consensus.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 4b92994..5e56ab9 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -25,8 +25,8 @@ import (
"sync"
"time"
- "github.com/dexon-foundation/dexon-consensus-core/blockdb"
"github.com/dexon-foundation/dexon-consensus-core/common"
+ "github.com/dexon-foundation/dexon-consensus-core/core/blockdb"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
"github.com/dexon-foundation/dexon-consensus-core/crypto"
)
@@ -145,7 +145,7 @@ func NewConsensus(
// Setup acking by information returned from Governace.
rb := newReliableBroadcast()
- rb.setChainNum(gov.GetChainNumber())
+ rb.setChainNum(gov.GetNumChains())
for vID := range validatorSet {
rb.addValidator(vID)
}
@@ -160,7 +160,7 @@ func NewConsensus(
to := newTotalOrdering(
uint64(gov.GetTotalOrderingK()),
uint64(float32(len(validatorSet)-1)*gov.GetPhiRatio()+1),
- gov.GetChainNumber())
+ gov.GetNumChains())
con := &Consensus{
ID: types.NewValidatorID(prv.PublicKey()),
@@ -179,9 +179,9 @@ func NewConsensus(
ctxCancel: ctxCancel,
}
- con.baModules = make([]*agreement, con.gov.GetChainNumber())
- con.receivers = make([]*consensusReceiver, con.gov.GetChainNumber())
- for i := uint32(0); i < con.gov.GetChainNumber(); i++ {
+ con.baModules = make([]*agreement, con.gov.GetNumChains())
+ con.receivers = make([]*consensusReceiver, con.gov.GetNumChains())
+ for i := uint32(0); i < con.gov.GetNumChains(); i++ {
chainID := i
con.receivers[chainID] = &consensusReceiver{
consensus: con,
@@ -208,8 +208,8 @@ func NewConsensus(
// Run starts running DEXON Consensus.
func (con *Consensus) Run() {
- ticks := make([]chan struct{}, 0, con.gov.GetChainNumber())
- for i := uint32(0); i < con.gov.GetChainNumber(); i++ {
+ ticks := make([]chan struct{}, 0, con.gov.GetNumChains())
+ for i := uint32(0); i < con.gov.GetNumChains(); i++ {
tick := make(chan struct{})
ticks = append(ticks, tick)
go con.runBA(i, tick)