mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
enable txPool flags
This commit is contained in:
parent
2a4d8db5da
commit
4e1b835434
1 changed files with 61 additions and 74 deletions
135
cmd/XDC/main.go
135
cmd/XDC/main.go
|
|
@ -58,17 +58,17 @@ var (
|
||||||
utils.BootnodesV5Flag,
|
utils.BootnodesV5Flag,
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.KeyStoreDirFlag,
|
utils.KeyStoreDirFlag,
|
||||||
utils.NoUSBFlag,
|
//utils.NoUSBFlag,
|
||||||
utils.DashboardEnabledFlag,
|
//utils.DashboardEnabledFlag,
|
||||||
utils.DashboardAddrFlag,
|
//utils.DashboardAddrFlag,
|
||||||
utils.DashboardPortFlag,
|
//utils.DashboardPortFlag,
|
||||||
utils.DashboardRefreshFlag,
|
//utils.DashboardRefreshFlag,
|
||||||
utils.EthashCacheDirFlag,
|
//utils.EthashCacheDirFlag,
|
||||||
utils.EthashCachesInMemoryFlag,
|
//utils.EthashCachesInMemoryFlag,
|
||||||
utils.EthashCachesOnDiskFlag,
|
//utils.EthashCachesOnDiskFlag,
|
||||||
utils.EthashDatasetDirFlag,
|
//utils.EthashDatasetDirFlag,
|
||||||
utils.EthashDatasetsInMemoryFlag,
|
//utils.EthashDatasetsInMemoryFlag,
|
||||||
utils.EthashDatasetsOnDiskFlag,
|
//utils.EthashDatasetsOnDiskFlag,
|
||||||
utils.TxPoolNoLocalsFlag,
|
utils.TxPoolNoLocalsFlag,
|
||||||
utils.TxPoolJournalFlag,
|
utils.TxPoolJournalFlag,
|
||||||
utils.TxPoolRejournalFlag,
|
utils.TxPoolRejournalFlag,
|
||||||
|
|
@ -83,13 +83,13 @@ var (
|
||||||
utils.LightModeFlag,
|
utils.LightModeFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.GCModeFlag,
|
utils.GCModeFlag,
|
||||||
utils.LightServFlag,
|
//utils.LightServFlag,
|
||||||
utils.LightPeersFlag,
|
//utils.LightPeersFlag,
|
||||||
utils.LightKDFFlag,
|
//utils.LightKDFFlag,
|
||||||
utils.CacheFlag,
|
//utils.CacheFlag,
|
||||||
utils.CacheDatabaseFlag,
|
//utils.CacheDatabaseFlag,
|
||||||
utils.CacheGCFlag,
|
//utils.CacheGCFlag,
|
||||||
utils.TrieCacheGenFlag,
|
//utils.TrieCacheGenFlag,
|
||||||
utils.ListenPortFlag,
|
utils.ListenPortFlag,
|
||||||
utils.MaxPeersFlag,
|
utils.MaxPeersFlag,
|
||||||
utils.MaxPendingPeersFlag,
|
utils.MaxPendingPeersFlag,
|
||||||
|
|
@ -100,25 +100,25 @@ var (
|
||||||
utils.TargetGasLimitFlag,
|
utils.TargetGasLimitFlag,
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
utils.NoDiscoverFlag,
|
utils.NoDiscoverFlag,
|
||||||
utils.DiscoveryV5Flag,
|
//utils.DiscoveryV5Flag,
|
||||||
utils.NetrestrictFlag,
|
//utils.NetrestrictFlag,
|
||||||
utils.NodeKeyFileFlag,
|
utils.NodeKeyFileFlag,
|
||||||
utils.NodeKeyHexFlag,
|
utils.NodeKeyHexFlag,
|
||||||
utils.DeveloperFlag,
|
//utils.DeveloperFlag,
|
||||||
utils.DeveloperPeriodFlag,
|
//utils.DeveloperPeriodFlag,
|
||||||
utils.TestnetFlag,
|
//utils.TestnetFlag,
|
||||||
utils.RinkebyFlag,
|
//utils.RinkebyFlag,
|
||||||
utils.VMEnableDebugFlag,
|
//utils.VMEnableDebugFlag,
|
||||||
utils.NetworkIdFlag,
|
utils.NetworkIdFlag,
|
||||||
utils.RPCCORSDomainFlag,
|
utils.RPCCORSDomainFlag,
|
||||||
utils.RPCVirtualHostsFlag,
|
utils.RPCVirtualHostsFlag,
|
||||||
utils.EthStatsURLFlag,
|
utils.EthStatsURLFlag,
|
||||||
utils.MetricsEnabledFlag,
|
utils.MetricsEnabledFlag,
|
||||||
utils.FakePoWFlag,
|
//utils.FakePoWFlag,
|
||||||
utils.NoCompactionFlag,
|
//utils.NoCompactionFlag,
|
||||||
utils.GpoBlocksFlag,
|
//utils.GpoBlocksFlag,
|
||||||
utils.GpoPercentileFlag,
|
//utils.GpoPercentileFlag,
|
||||||
utils.ExtraDataFlag,
|
//utils.ExtraDataFlag,
|
||||||
configFileFlag,
|
configFileFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,13 +153,8 @@ func init() {
|
||||||
initCommand,
|
initCommand,
|
||||||
importCommand,
|
importCommand,
|
||||||
exportCommand,
|
exportCommand,
|
||||||
importPreimagesCommand,
|
|
||||||
exportPreimagesCommand,
|
|
||||||
copydbCommand,
|
|
||||||
removedbCommand,
|
removedbCommand,
|
||||||
dumpCommand,
|
dumpCommand,
|
||||||
// See monitorcmd.go:
|
|
||||||
monitorCommand,
|
|
||||||
// See accountcmd.go:
|
// See accountcmd.go:
|
||||||
accountCommand,
|
accountCommand,
|
||||||
walletCommand,
|
walletCommand,
|
||||||
|
|
@ -168,11 +163,7 @@ func init() {
|
||||||
attachCommand,
|
attachCommand,
|
||||||
javascriptCommand,
|
javascriptCommand,
|
||||||
// See misccmd.go:
|
// See misccmd.go:
|
||||||
makecacheCommand,
|
|
||||||
makedagCommand,
|
|
||||||
versionCommand,
|
versionCommand,
|
||||||
bugCommand,
|
|
||||||
licenseCommand,
|
|
||||||
// See config.go
|
// See config.go
|
||||||
dumpConfigCommand,
|
dumpConfigCommand,
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +173,7 @@ func init() {
|
||||||
app.Flags = append(app.Flags, rpcFlags...)
|
app.Flags = append(app.Flags, rpcFlags...)
|
||||||
app.Flags = append(app.Flags, consoleFlags...)
|
app.Flags = append(app.Flags, consoleFlags...)
|
||||||
app.Flags = append(app.Flags, debug.Flags...)
|
app.Flags = append(app.Flags, debug.Flags...)
|
||||||
app.Flags = append(app.Flags, whisperFlags...)
|
//app.Flags = append(app.Flags, whisperFlags...)
|
||||||
|
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
@ -297,12 +288,12 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg XDCConfig) {
|
||||||
if _, ok := ethereum.Engine().(*XDPoS.XDPoS); ok {
|
if _, ok := ethereum.Engine().(*XDPoS.XDPoS); ok {
|
||||||
go func() {
|
go func() {
|
||||||
started := false
|
started := false
|
||||||
ok, err := ethereum.ValidateStaker()
|
ok, err := ethereum.ValidateMasternode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Can't verify validator permission: %v", err)
|
utils.Fatalf("Can't verify masternode permission: %v", err)
|
||||||
}
|
}
|
||||||
if ok {
|
if ok {
|
||||||
log.Info("Validator found. Enabling staking mode...")
|
log.Info("Masternode found. Enabling staking mode...")
|
||||||
// Use a reduced number of threads if requested
|
// Use a reduced number of threads if requested
|
||||||
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
|
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
|
||||||
type threaded interface {
|
type threaded interface {
|
||||||
|
|
@ -321,41 +312,37 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg XDCConfig) {
|
||||||
log.Info("Enabled staking node!!!")
|
log.Info("Enabled staking node!!!")
|
||||||
}
|
}
|
||||||
defer close(core.CheckpointCh)
|
defer close(core.CheckpointCh)
|
||||||
for {
|
for range core.CheckpointCh {
|
||||||
select {
|
log.Info("Checkpoint!!! It's time to reconcile node's state...")
|
||||||
case <-core.CheckpointCh:
|
ok, err := ethereum.ValidateMasternode()
|
||||||
log.Info("Checkpoint!!! It's time to reconcile node's state...")
|
if err != nil {
|
||||||
ok, err := ethereum.ValidateStaker()
|
utils.Fatalf("Can't verify masternode permission: %v", err)
|
||||||
if err != nil {
|
}
|
||||||
utils.Fatalf("Can't verify masternode permission: %v", err)
|
if !ok {
|
||||||
|
if started {
|
||||||
|
log.Info("Only masternode can propose and verify blocks. Cancelling staking on this node...")
|
||||||
|
ethereum.StopStaking()
|
||||||
|
started = false
|
||||||
|
log.Info("Cancelled mining mode!!!")
|
||||||
}
|
}
|
||||||
if !ok {
|
} else if !started {
|
||||||
if started {
|
log.Info("Masternode found. Enabling staking mode...")
|
||||||
log.Info("Only masternode can propose and verify blocks. Cancelling staking on this node...")
|
// Use a reduced number of threads if requested
|
||||||
ethereum.StopStaking()
|
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
|
||||||
started = false
|
type threaded interface {
|
||||||
log.Info("Cancelled mining mode!!!")
|
SetThreads(threads int)
|
||||||
}
|
}
|
||||||
} else if !started {
|
if th, ok := ethereum.Engine().(threaded); ok {
|
||||||
log.Info("Masternode found. Enabling staking mode...")
|
th.SetThreads(threads)
|
||||||
// Use a reduced number of threads if requested
|
|
||||||
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
|
|
||||||
type threaded interface {
|
|
||||||
SetThreads(threads int)
|
|
||||||
}
|
|
||||||
if th, ok := ethereum.Engine().(threaded); ok {
|
|
||||||
th.SetThreads(threads)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Set the gas price to the limits from the CLI and start mining
|
|
||||||
ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice)
|
|
||||||
if err := ethereum.StartStaking(true); err != nil {
|
|
||||||
utils.Fatalf("Failed to start staking: %v", err)
|
|
||||||
}
|
|
||||||
started = true
|
|
||||||
log.Info("Enabled staking node!!!")
|
|
||||||
}
|
}
|
||||||
|
// Set the gas price to the limits from the CLI and start mining
|
||||||
|
ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice)
|
||||||
|
if err := ethereum.StartStaking(true); err != nil {
|
||||||
|
utils.Fatalf("Failed to start staking: %v", err)
|
||||||
|
}
|
||||||
|
started = true
|
||||||
|
log.Info("Enabled staking node!!!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue