Skip to content

Commit

Permalink
Merge pull request ethereum#114 from etclabscore/fix/resolve-91-review
Browse files Browse the repository at this point in the history
Fix/resolve 91 review
  • Loading branch information
meowsbits authored Jan 2, 2020
2 parents 6020a14 + 651a2d1 commit 3067eb5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion params/confp/tconvert/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ It represents vestigial constructions for converting between chain configuration
data types. I believe all functions are used only in the cmd/puppeth package.
These functions should be replaced in their occurrences with `convert.Convert` logic instead,
and then this package can
and then this package can die.
*/
package tconvert
35 changes: 16 additions & 19 deletions params/types/goethereum/goethereum_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ func setBig(i *big.Int, u *uint64) *big.Int {
}

func (c *ChainConfig) GetAccountStartNonce() *uint64 {
return internal.One().GetAccountStartNonce()
return internal.GlobalConfigurator().GetAccountStartNonce()
}

func (c *ChainConfig) SetAccountStartNonce(n *uint64) error {
return internal.One().SetAccountStartNonce(n)
return internal.GlobalConfigurator().SetAccountStartNonce(n)
}

func (c *ChainConfig) GetMaximumExtraDataSize() *uint64 {
return internal.One().GetMaximumExtraDataSize()
return internal.GlobalConfigurator().GetMaximumExtraDataSize()
}

func (c *ChainConfig) SetMaximumExtraDataSize(n *uint64) error {
return internal.One().SetMaximumExtraDataSize(n)
return internal.GlobalConfigurator().SetMaximumExtraDataSize(n)
}

func (c *ChainConfig) GetMinGasLimit() *uint64 {
return internal.One().GetMinGasLimit()
return internal.GlobalConfigurator().GetMinGasLimit()
}

func (c *ChainConfig) SetMinGasLimit(n *uint64) error {
return internal.One().SetMinGasLimit(n)
return internal.GlobalConfigurator().SetMinGasLimit(n)
}

func (c *ChainConfig) GetGasLimitBoundDivisor() *uint64 {
return internal.One().GetGasLimitBoundDivisor()
return internal.GlobalConfigurator().GetGasLimitBoundDivisor()
}

func (c *ChainConfig) SetGasLimitBoundDivisor(n *uint64) error {
return internal.One().SetGasLimitBoundDivisor(n)
return internal.GlobalConfigurator().SetGasLimitBoundDivisor(n)
}

// GetNetworkID and the following Set/Getters for ChainID too
Expand Down Expand Up @@ -121,11 +121,11 @@ func (c *ChainConfig) SetChainID(n *big.Int) error {
}

func (c *ChainConfig) GetMaxCodeSize() *uint64 {
return internal.One().GetMaxCodeSize()
return internal.GlobalConfigurator().GetMaxCodeSize()
}

func (c *ChainConfig) SetMaxCodeSize(n *uint64) error {
return internal.One().SetMaxCodeSize(n)
return internal.GlobalConfigurator().SetMaxCodeSize(n)
}

func (c *ChainConfig) GetEIP7Transition() *uint64 {
Expand Down Expand Up @@ -386,9 +386,6 @@ func (c *ChainConfig) GetForkCanonHashes() map[uint64]common.Hash {
}

func (c *ChainConfig) GetConsensusEngineType() ctypes.ConsensusEngineT {
if c.Ethash != nil {
return ctypes.ConsensusEngineT_Ethash
}
if c.Clique != nil {
return ctypes.ConsensusEngineT_Clique
}
Expand All @@ -409,27 +406,27 @@ func (c *ChainConfig) MustSetConsensusEngineType(t ctypes.ConsensusEngineT) erro
}

func (c *ChainConfig) GetEthashMinimumDifficulty() *big.Int {
return internal.One().GetEthashMinimumDifficulty()
return internal.GlobalConfigurator().GetEthashMinimumDifficulty()
}

func (c *ChainConfig) SetEthashMinimumDifficulty(i *big.Int) error {
return internal.One().SetEthashMinimumDifficulty(i)
return internal.GlobalConfigurator().SetEthashMinimumDifficulty(i)
}

func (c *ChainConfig) GetEthashDifficultyBoundDivisor() *big.Int {
return internal.One().GetEthashDifficultyBoundDivisor()
return internal.GlobalConfigurator().GetEthashDifficultyBoundDivisor()
}

func (c *ChainConfig) SetEthashDifficultyBoundDivisor(i *big.Int) error {
return internal.One().SetEthashDifficultyBoundDivisor(i)
return internal.GlobalConfigurator().SetEthashDifficultyBoundDivisor(i)
}

func (c *ChainConfig) GetEthashDurationLimit() *big.Int {
return internal.One().GetEthashDurationLimit()
return internal.GlobalConfigurator().GetEthashDurationLimit()
}

func (c *ChainConfig) SetEthashDurationLimit(i *big.Int) error {
return internal.One().SetEthashDurationLimit(i)
return internal.GlobalConfigurator().SetEthashDurationLimit(i)
}

// NOTE: Checking for if c.Ethash == nil is a consideration.
Expand Down
38 changes: 20 additions & 18 deletions params/types/internal/vars_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import (
type GlobalVarsConfigurator struct {
}

func One() *GlobalVarsConfigurator {
return &GlobalVarsConfigurator{}
var gc = &GlobalVarsConfigurator{}

func GlobalConfigurator() *GlobalVarsConfigurator {
return gc
}

func newU64(u uint64) *uint64 {
return &u
}

func (g GlobalVarsConfigurator) GetAccountStartNonce() *uint64 {
func (_ GlobalVarsConfigurator) GetAccountStartNonce() *uint64 {
return newU64(0)
}

func (g GlobalVarsConfigurator) SetAccountStartNonce(n *uint64) error {
func (_ GlobalVarsConfigurator) SetAccountStartNonce(n *uint64) error {
if n == nil {
return nil
}
Expand All @@ -32,73 +34,73 @@ func (g GlobalVarsConfigurator) SetAccountStartNonce(n *uint64) error {
return nil
}

func (g GlobalVarsConfigurator) GetMaximumExtraDataSize() *uint64 {
func (_ GlobalVarsConfigurator) GetMaximumExtraDataSize() *uint64 {
return newU64(vars.MaximumExtraDataSize)
}

func (g GlobalVarsConfigurator) SetMaximumExtraDataSize(n *uint64) error {
func (_ GlobalVarsConfigurator) SetMaximumExtraDataSize(n *uint64) error {
vars.MaximumExtraDataSize = *n
return nil
}

func (g GlobalVarsConfigurator) GetMinGasLimit() *uint64 {
func (_ GlobalVarsConfigurator) GetMinGasLimit() *uint64 {
return newU64(vars.MinGasLimit)
}

func (g GlobalVarsConfigurator) SetMinGasLimit(n *uint64) error {
func (_ GlobalVarsConfigurator) SetMinGasLimit(n *uint64) error {
vars.MinGasLimit = *n
return nil
}

func (g GlobalVarsConfigurator) GetGasLimitBoundDivisor() *uint64 {
func (_ GlobalVarsConfigurator) GetGasLimitBoundDivisor() *uint64 {
return newU64(vars.GasLimitBoundDivisor)
}

func (g GlobalVarsConfigurator) SetGasLimitBoundDivisor(n *uint64) error {
func (_ GlobalVarsConfigurator) SetGasLimitBoundDivisor(n *uint64) error {
vars.GasLimitBoundDivisor = *n
return nil
}

func (g GlobalVarsConfigurator) GetMaxCodeSize() *uint64 {
func (_ GlobalVarsConfigurator) GetMaxCodeSize() *uint64 {
return newU64(vars.MaxCodeSize)
}

func (g GlobalVarsConfigurator) SetMaxCodeSize(n *uint64) error {
func (_ GlobalVarsConfigurator) SetMaxCodeSize(n *uint64) error {
if n == nil {
return nil
}
vars.MaxCodeSize = *n
return nil
}

func (c GlobalVarsConfigurator) GetEthashMinimumDifficulty() *big.Int {
func (_ GlobalVarsConfigurator) GetEthashMinimumDifficulty() *big.Int {
return vars.MinimumDifficulty
}
func (c GlobalVarsConfigurator) SetEthashMinimumDifficulty(i *big.Int) error {
func (_ GlobalVarsConfigurator) SetEthashMinimumDifficulty(i *big.Int) error {
if i == nil {
return ctypes.ErrUnsupportedConfigFatal
}
vars.MinimumDifficulty = i
return nil
}

func (c GlobalVarsConfigurator) GetEthashDifficultyBoundDivisor() *big.Int {
func (_ GlobalVarsConfigurator) GetEthashDifficultyBoundDivisor() *big.Int {
return vars.DifficultyBoundDivisor
}

func (c GlobalVarsConfigurator) SetEthashDifficultyBoundDivisor(i *big.Int) error {
func (_ GlobalVarsConfigurator) SetEthashDifficultyBoundDivisor(i *big.Int) error {
if i == nil {
return ctypes.ErrUnsupportedConfigFatal
}
vars.DifficultyBoundDivisor = i
return nil
}

func (c GlobalVarsConfigurator) GetEthashDurationLimit() *big.Int {
func (_ GlobalVarsConfigurator) GetEthashDurationLimit() *big.Int {
return vars.DurationLimit
}

func (c GlobalVarsConfigurator) SetEthashDurationLimit(i *big.Int) error {
func (_ GlobalVarsConfigurator) SetEthashDurationLimit(i *big.Int) error {
if i == nil {
return ctypes.ErrUnsupportedConfigFatal
}
Expand Down
32 changes: 16 additions & 16 deletions params/types/multigeth/chain_config_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,28 @@ func (c *MultiGethChainConfig) ensureExistingDifficultySchedule() {
}

func (c *MultiGethChainConfig) GetAccountStartNonce() *uint64 {
return internal.One().GetAccountStartNonce()
return internal.GlobalConfigurator().GetAccountStartNonce()
}
func (c *MultiGethChainConfig) SetAccountStartNonce(n *uint64) error {
return internal.One().SetAccountStartNonce(n)
return internal.GlobalConfigurator().SetAccountStartNonce(n)
}
func (c *MultiGethChainConfig) GetMaximumExtraDataSize() *uint64 {
return internal.One().GetMaximumExtraDataSize()
return internal.GlobalConfigurator().GetMaximumExtraDataSize()
}
func (c *MultiGethChainConfig) SetMaximumExtraDataSize(n *uint64) error {
return internal.One().SetMaximumExtraDataSize(n)
return internal.GlobalConfigurator().SetMaximumExtraDataSize(n)
}
func (c *MultiGethChainConfig) GetMinGasLimit() *uint64 {
return internal.One().GetMinGasLimit()
return internal.GlobalConfigurator().GetMinGasLimit()
}
func (c *MultiGethChainConfig) SetMinGasLimit(n *uint64) error {
return internal.One().SetMinGasLimit(n)
return internal.GlobalConfigurator().SetMinGasLimit(n)
}
func (c *MultiGethChainConfig) GetGasLimitBoundDivisor() *uint64 {
return internal.One().GetGasLimitBoundDivisor()
return internal.GlobalConfigurator().GetGasLimitBoundDivisor()
}
func (c *MultiGethChainConfig) SetGasLimitBoundDivisor(n *uint64) error {
return internal.One().SetGasLimitBoundDivisor(n)
return internal.GlobalConfigurator().SetGasLimitBoundDivisor(n)
}

func (c *MultiGethChainConfig) GetNetworkID() *uint64 {
Expand All @@ -114,10 +114,10 @@ func (c *MultiGethChainConfig) SetChainID(n *big.Int) error {
}

func (c *MultiGethChainConfig) GetMaxCodeSize() *uint64 {
return internal.One().GetMaxCodeSize()
return internal.GlobalConfigurator().GetMaxCodeSize()
}
func (c *MultiGethChainConfig) SetMaxCodeSize(n *uint64) error {
return internal.One().SetMaxCodeSize(n)
return internal.GlobalConfigurator().SetMaxCodeSize(n)
}

func (c *MultiGethChainConfig) GetEIP7Transition() *uint64 {
Expand Down Expand Up @@ -401,26 +401,26 @@ func (c *MultiGethChainConfig) MustSetConsensusEngineType(t ctypes.ConsensusEngi
}

func (c *MultiGethChainConfig) GetEthashMinimumDifficulty() *big.Int {
return internal.One().GetEthashMinimumDifficulty()
return internal.GlobalConfigurator().GetEthashMinimumDifficulty()
}
func (c *MultiGethChainConfig) SetEthashMinimumDifficulty(i *big.Int) error {
return internal.One().SetEthashMinimumDifficulty(i)
return internal.GlobalConfigurator().SetEthashMinimumDifficulty(i)
}

func (c *MultiGethChainConfig) GetEthashDifficultyBoundDivisor() *big.Int {
return internal.One().GetEthashDifficultyBoundDivisor()
return internal.GlobalConfigurator().GetEthashDifficultyBoundDivisor()
}

func (c *MultiGethChainConfig) SetEthashDifficultyBoundDivisor(i *big.Int) error {
return internal.One().SetEthashDifficultyBoundDivisor(i)
return internal.GlobalConfigurator().SetEthashDifficultyBoundDivisor(i)
}

func (c *MultiGethChainConfig) GetEthashDurationLimit() *big.Int {
return internal.One().GetEthashDurationLimit()
return internal.GlobalConfigurator().GetEthashDurationLimit()
}

func (c *MultiGethChainConfig) SetEthashDurationLimit(i *big.Int) error {
return internal.One().SetEthashDurationLimit(i)
return internal.GlobalConfigurator().SetEthashDurationLimit(i)
}

func (c *MultiGethChainConfig) GetEthashHomesteadTransition() *uint64 {
Expand Down

0 comments on commit 3067eb5

Please sign in to comment.