aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-22 11:49:29 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit0282d618a97878f45fec8fff4f2cb3ded31f78f8 (patch)
tree11283430ec2321a48e875113f29d7b79cb15af2d
parent429d5cb30e0883b5f2e68fb7a3b38c80836df5f5 (diff)
downloaddexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar.gz
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar.bz2
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar.lz
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar.xz
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.tar.zst
dexon-0282d618a97878f45fec8fff4f2cb3ded31f78f8.zip
geth: add propose flag to enable/disable proposing
-rw-r--r--cmd/geth/main.go15
-rw-r--r--cmd/geth/usage.go6
-rw-r--r--cmd/utils/flags.go5
-rw-r--r--dex/backend.go7
4 files changed, 33 insertions, 0 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 3b604b181..4ff0f42b3 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -31,6 +31,7 @@ import (
"github.com/dexon-foundation/dexon/accounts/keystore"
"github.com/dexon-foundation/dexon/cmd/utils"
"github.com/dexon-foundation/dexon/console"
+ "github.com/dexon-foundation/dexon/dex"
"github.com/dexon-foundation/dexon/eth"
"github.com/dexon-foundation/dexon/ethclient"
"github.com/dexon-foundation/dexon/internal/debug"
@@ -96,6 +97,7 @@ var (
utils.ListenPortFlag,
utils.MaxPeersFlag,
utils.MaxPendingPeersFlag,
+ utils.ProposingEnabledFlag,
utils.MiningEnabledFlag,
utils.MinerThreadsFlag,
utils.MinerLegacyThreadsFlag,
@@ -354,4 +356,17 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.Fatalf("Failed to start mining: %v", err)
}
}
+
+ if ctx.GlobalBool(utils.ProposingEnabledFlag.Name) {
+ if ctx.GlobalString(utils.SyncModeFlag.Name) == "light" {
+ utils.Fatalf("Light clients do not support proposing")
+ }
+ var dexon *dex.Dexon
+ if err := stack.Service(&dexon); err != nil {
+ utils.Fatalf("Dexon service not running: %v", err)
+ }
+ if err := dexon.StartProposing(); err != nil {
+ utils.Fatalf("Failed to string proposing: %v", err)
+ }
+ }
}
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 941ae5b8e..911095c50 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -183,6 +183,12 @@ var AppHelpFlagGroups = []flagGroup{
},
},
{
+ Name: "PROPOSER",
+ Flags: []cli.Flag{
+ utils.ProposingEnabledFlag,
+ },
+ },
+ {
Name: "MINER",
Flags: []cli.Flag{
utils.MiningEnabledFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 693de5f66..5a6a6476f 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -316,6 +316,11 @@ var (
Usage: "Number of trie node generations to keep in memory",
Value: int(state.MaxTrieCacheGen),
}
+ // Proposer settings
+ ProposingEnabledFlag = cli.BoolFlag{
+ Name: "propose",
+ Usage: "Enable proposing",
+ }
// Miner settings
MiningEnabledFlag = cli.BoolFlag{
Name: "mine",
diff --git a/dex/backend.go b/dex/backend.go
index 26729ca25..dd2312e35 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -255,6 +255,13 @@ func (s *Dexon) Stop() error {
return nil
}
+func (s *Dexon) StartProposing() error {
+ // TODO(sonic):
+ // enable dispatch vote, agreement result, finalization result.. msg to consensus core.
+ log.Debug("###############start proposing")
+ return nil
+}
+
// CreateDB creates the chain database.
func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) {
db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles)