mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
eth: use gasprice.Config instead of duplicating its fields
This commit is contained in:
parent
f65fa21dc1
commit
12d627ee90
6 changed files with 28 additions and 31 deletions
|
|
@ -37,6 +37,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/ethstats"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
|
|
@ -411,12 +412,12 @@ var (
|
|||
GpoBlocksFlag = cli.IntFlag{
|
||||
Name: "gpoblocks",
|
||||
Usage: "Number of recent blocks to check for gas prices",
|
||||
Value: eth.DefaultConfig.GpoBlocks,
|
||||
Value: eth.DefaultConfig.GPO.Blocks,
|
||||
}
|
||||
GpoPercentileFlag = cli.IntFlag{
|
||||
Name: "gpopercentile",
|
||||
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
|
||||
Value: eth.DefaultConfig.GpoPercentile,
|
||||
Value: eth.DefaultConfig.GPO.Percentile,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -761,12 +762,12 @@ func MakeNode(ctx *cli.Context, name, gitCommit string) *node.Node {
|
|||
return stack
|
||||
}
|
||||
|
||||
func setGPO(ctx *cli.Context, cfg *eth.Config) {
|
||||
func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
|
||||
if ctx.GlobalIsSet(GpoBlocksFlag.Name) {
|
||||
cfg.GpoBlocks = ctx.GlobalInt(GpoBlocksFlag.Name)
|
||||
cfg.Blocks = ctx.GlobalInt(GpoBlocksFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(GpoPercentileFlag.Name) {
|
||||
cfg.GpoPercentile = ctx.GlobalInt(GpoPercentileFlag.Name)
|
||||
cfg.Percentile = ctx.GlobalInt(GpoPercentileFlag.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -806,7 +807,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
|||
|
||||
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
||||
setEtherbase(ctx, ks, cfg)
|
||||
setGPO(ctx, cfg)
|
||||
setGPO(ctx, &cfg.GPO)
|
||||
setEthash(ctx, cfg)
|
||||
|
||||
if ctx.GlobalIsSet(FastSyncFlag.Name) {
|
||||
|
|
|
|||
|
|
@ -165,10 +165,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
eth.miner.SetExtra(makeExtraData(config.ExtraData))
|
||||
|
||||
eth.ApiBackend = &EthApiBackend{eth, nil}
|
||||
gpoParams := gasprice.Config{
|
||||
Blocks: config.GpoBlocks,
|
||||
Percentile: config.GpoPercentile,
|
||||
Default: config.GasPrice,
|
||||
gpoParams := config.GPO
|
||||
if gpoParams.Default == nil {
|
||||
gpoParams.Default = config.GasPrice
|
||||
}
|
||||
eth.ApiBackend.gpo = gasprice.NewOracle(eth.ApiBackend, gpoParams)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
|
|
@ -38,8 +39,11 @@ var DefaultConfig = Config{
|
|||
LightPeers: 20,
|
||||
DatabaseCache: 128,
|
||||
GasPrice: big.NewInt(20 * params.Shannon),
|
||||
GpoBlocks: 10,
|
||||
GpoPercentile: 50,
|
||||
|
||||
GPO: gasprice.Config{
|
||||
Blocks: 10,
|
||||
Percentile: 50,
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
@ -93,8 +97,7 @@ type Config struct {
|
|||
EthashDatasetsOnDisk int
|
||||
|
||||
// Gas Price Oracle options
|
||||
GpoBlocks int
|
||||
GpoPercentile int
|
||||
GPO gasprice.Config `toml:"gpo"`
|
||||
|
||||
// Enables tracking of SHA3 preimages in the VM
|
||||
EnablePreimageRecording bool
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
)
|
||||
|
||||
func (c Config) MarshalTOML() (interface{}, error) {
|
||||
|
|
@ -32,8 +33,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
EthashDatasetDir string
|
||||
EthashDatasetsInMem int
|
||||
EthashDatasetsOnDisk int
|
||||
GpoBlocks int
|
||||
GpoPercentile int
|
||||
GPO gasprice.Config `toml:"gpo"`
|
||||
EnablePreimageRecording bool
|
||||
SolcPath string
|
||||
DocRoot string `toml:"-"`
|
||||
|
|
@ -62,8 +62,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
enc.EthashDatasetDir = c.EthashDatasetDir
|
||||
enc.EthashDatasetsInMem = c.EthashDatasetsInMem
|
||||
enc.EthashDatasetsOnDisk = c.EthashDatasetsOnDisk
|
||||
enc.GpoBlocks = c.GpoBlocks
|
||||
enc.GpoPercentile = c.GpoPercentile
|
||||
enc.GPO = c.GPO
|
||||
enc.EnablePreimageRecording = c.EnablePreimageRecording
|
||||
enc.SolcPath = c.SolcPath
|
||||
enc.DocRoot = c.DocRoot
|
||||
|
|
@ -95,8 +94,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
EthashDatasetDir *string
|
||||
EthashDatasetsInMem *int
|
||||
EthashDatasetsOnDisk *int
|
||||
GpoBlocks *int
|
||||
GpoPercentile *int
|
||||
GPO *gasprice.Config `toml:"gpo"`
|
||||
EnablePreimageRecording *bool
|
||||
SolcPath *string
|
||||
DocRoot *string `toml:"-"`
|
||||
|
|
@ -168,11 +166,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
if dec.EthashDatasetsOnDisk != nil {
|
||||
c.EthashDatasetsOnDisk = *dec.EthashDatasetsOnDisk
|
||||
}
|
||||
if dec.GpoBlocks != nil {
|
||||
c.GpoBlocks = *dec.GpoBlocks
|
||||
}
|
||||
if dec.GpoPercentile != nil {
|
||||
c.GpoPercentile = *dec.GpoPercentile
|
||||
if dec.GPO != nil {
|
||||
c.GPO = *dec.GPO
|
||||
}
|
||||
if dec.EnablePreimageRecording != nil {
|
||||
c.EnablePreimageRecording = *dec.EnablePreimageRecording
|
||||
|
|
|
|||
|
|
@ -111,10 +111,9 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
|
|||
relay.reqDist = eth.protocolManager.reqDist
|
||||
|
||||
eth.ApiBackend = &LesApiBackend{eth, nil}
|
||||
gpoParams := gasprice.Config{
|
||||
Blocks: config.GpoBlocks,
|
||||
Percentile: config.GpoPercentile,
|
||||
Default: config.GasPrice,
|
||||
gpoParams := config.GPO
|
||||
if gpoParams.Default == nil {
|
||||
gpoParams.Default = config.GasPrice
|
||||
}
|
||||
eth.ApiBackend.gpo = gasprice.NewOracle(eth.ApiBackend, gpoParams)
|
||||
return eth, nil
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/ethstats"
|
||||
"github.com/ethereum/go-ethereum/les"
|
||||
|
|
@ -151,8 +152,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
|||
DatabaseCache: config.EthereumDatabaseCache,
|
||||
NetworkId: config.EthereumNetworkID,
|
||||
GasPrice: new(big.Int).SetUint64(20 * params.Shannon),
|
||||
GpoBlocks: 10,
|
||||
GpoPercentile: 50,
|
||||
GPO: gasprice.Config{Blocks: 10, Percentile: 50},
|
||||
EthashCacheDir: "ethash",
|
||||
EthashCachesInMem: 2,
|
||||
EthashCachesOnDisk: 3,
|
||||
|
|
|
|||
Loading…
Reference in a new issue