aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-09-03 11:04:05 +0800
committerGitHub <noreply@github.com>2018-09-03 11:04:05 +0800
commit3410f1156703a7249bade6e3cc90b60a1fcefa54 (patch)
treee75bdecc1207322720335d33cf778c2d0c820323
parentc8d3092208f73ee991a123052a71b7dbf7fffc27 (diff)
downloaddexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar.gz
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar.bz2
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar.lz
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar.xz
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.tar.zst
dexon-consensus-3410f1156703a7249bade6e3cc90b60a1fcefa54.zip
core: minor change to governance interface (#90)
-rw-r--r--core/governance.go49
-rw-r--r--core/interfaces.go28
-rw-r--r--core/test/governance.go5
-rw-r--r--core/types/configuration.go10
-rw-r--r--simulation/governance.go5
5 files changed, 30 insertions, 67 deletions
diff --git a/core/governance.go b/core/governance.go
deleted file mode 100644
index 9ace833..0000000
--- a/core/governance.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2018 The dexon-consensus-core Authors
-// This file is part of the dexon-consensus-core library.
-//
-// The dexon-consensus-core library is free software: you can redistribute it
-// and/or modify it under the terms of the GNU Lesser General Public License as
-// published by the Free Software Foundation, either version 3 of the License,
-// or (at your option) any later version.
-//
-// The dexon-consensus-core library is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
-// General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the dexon-consensus-core library. If not, see
-// <http://www.gnu.org/licenses/>.
-
-package core
-
-import (
- "github.com/shopspring/decimal"
-
- "github.com/dexon-foundation/dexon-consensus-core/core/types"
-)
-
-// Governance interface specifies interface to control the governance contract.
-// Note that there are a lot more methods in the governance contract, that this
-// interface only define those that are required to run the consensus algorithm.
-type Governance interface {
- // Get the current validator set and it's corresponding stake.
- GetValidatorSet() map[types.ValidatorID]decimal.Decimal
-
- // Get K
- GetTotalOrderingK() int
-
- // Get PhiRatio
- GetPhiRatio() float32
-
- // Get block proposing interval (in milliseconds).
- GetBlockProposingInterval() int
-
- // Get configuration change events after a certain epoch.
- GetConfigurationChangeEvent(epoch int) []types.ConfigurationChangeEvent
-
- // Get Genesis CRS.
- GetGenesisCRS() string
- // GetAgreementK returns number of blocks for a CRS.
- GetAgreementK() int
-}
diff --git a/core/interfaces.go b/core/interfaces.go
index 55df106..44f2308 100644
--- a/core/interfaces.go
+++ b/core/interfaces.go
@@ -20,6 +20,8 @@ package core
import (
"time"
+ "github.com/shopspring/decimal"
+
"github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
)
@@ -55,10 +57,36 @@ type Application interface {
type Network interface {
// BroadcastVote broadcasts vote to all nodes in DEXON network.
BroadcastVote(vote *types.Vote)
+
// BroadcastBlock broadcasts block to all nodes in DEXON network.
BroadcastBlock(block *types.Block)
+
// BroadcastNotaryAck broadcasts notaryAck to all nodes in DEXON network.
BroadcastNotaryAck(notaryAck *types.NotaryAck)
+
// ReceiveChan returns a channel to receive messages from DEXON network.
ReceiveChan() <-chan interface{}
}
+
+// Governance interface specifies interface to control the governance contract.
+// Note that there are a lot more methods in the governance contract, that this
+// interface only define those that are required to run the consensus algorithm.
+type Governance interface {
+ // Get the current validator set and it's corresponding stake.
+ GetValidatorSet() map[types.ValidatorID]decimal.Decimal
+
+ // Get K.
+ GetTotalOrderingK() int
+
+ // Get PhiRatio.
+ GetPhiRatio() float32
+
+ // Get block proposing interval (in milliseconds).
+ GetBlockProposingInterval() int
+
+ // Get Genesis CRS.
+ GetGenesisCRS() string
+
+ // Get configuration change events after an epoch.
+ GetConfigurationChangeEvent(epoch int) []types.ConfigurationChangeEvent
+}
diff --git a/core/test/governance.go b/core/test/governance.go
index 8df7e80..681c3b5 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -93,11 +93,6 @@ func (g *Governance) GetGenesisCRS() string {
return "🆕 DEXON"
}
-// GetAgreementK returns number of blocks for a CRS.
-func (g *Governance) GetAgreementK() int {
- return 20
-}
-
// GetPrivateKey return the private key for that validator, this function
// is a test utility and not a general core.Governance interface.
func (g *Governance) GetPrivateKey(
diff --git a/core/types/configuration.go b/core/types/configuration.go
index 4158331..6011b19 100644
--- a/core/types/configuration.go
+++ b/core/types/configuration.go
@@ -23,8 +23,8 @@ type ConfigurationChangeEventType int
// Event enums.
const (
KChanged ConfigurationChangeEventType = iota
- MembershipAdd
- MembershipRemove
+ PhiRatioChanged
+ BlockProposingIntervalChanged
)
// IntegerEventPayload is a general payload for integer type value.
@@ -32,12 +32,6 @@ type IntegerEventPayload struct {
Value int64
}
-// MembershipEventPayload is the payload type for membership event.
-type MembershipEventPayload struct {
- ID ValidatorID
- Evidence []byte
-}
-
// ConfigurationChangeEvent specifies the event of membership changes.
type ConfigurationChangeEvent struct {
Epoch int
diff --git a/simulation/governance.go b/simulation/governance.go
index 7100d4c..42577d9 100644
--- a/simulation/governance.go
+++ b/simulation/governance.go
@@ -93,11 +93,6 @@ func (g *simGovernance) GetGenesisCRS() string {
return g.crs
}
-// GetAgreementK returns K for agreement.
-func (g *simGovernance) GetAgreementK() int {
- return g.agreementK
-}
-
// addValidator add a new validator into the simulated governance contract.
func (g *simGovernance) addValidator(vID types.ValidatorID) {
g.lock.Lock()