Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (api *EthereumAPI) Mining() bool {

func (api *EthereumAPI) ChainId() hexutil.Uint64 {
chainID := new(big.Int)
if config := api.e.chainConfig; config.IsEIP155(api.e.blockchain.CurrentBlock().Number) {
if config := api.e.blockchain.Config(); config.IsEIP155(api.e.blockchain.CurrentBlock().Number) {
chainID = config.ChainID
}
return (hexutil.Uint64)(chainID.Uint64())
Expand Down
8 changes: 4 additions & 4 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type EthAPIBackend struct {
}

func (b *EthAPIBackend) ChainConfig() *params.ChainConfig {
return b.eth.chainConfig
return b.eth.blockchain.Config()
}

func (b *EthAPIBackend) CurrentBlock() *types.Header {
Expand All @@ -85,7 +85,7 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb
return b.eth.blockchain.CurrentBlock(), nil
}
if number == rpc.FinalizedBlockNumber {
if b.eth.chainConfig.XDPoS == nil {
if b.eth.blockchain.Config().XDPoS == nil {
return nil, errors.New("PoW does not support confirmed block lookup")
}
current := b.eth.blockchain.CurrentBlock()
Expand Down Expand Up @@ -138,7 +138,7 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
}
if number == rpc.FinalizedBlockNumber {
if b.eth.chainConfig.XDPoS == nil {
if b.eth.blockchain.Config().XDPoS == nil {
return nil, errors.New("PoW does not support confirmed block lookup")
}
current := b.eth.blockchain.CurrentBlock()
Expand Down Expand Up @@ -273,7 +273,7 @@ func (b *EthAPIBackend) GetEVM(ctx context.Context, state *state.StateDB, XDCxSt
} else {
context = core.NewEVMBlockContext(header, b.eth.BlockChain(), nil)
}
return vm.NewEVM(context, state, XDCxState, b.eth.chainConfig, *vmConfig), vmError, nil
return vm.NewEVM(context, state, XDCxState, b.eth.blockchain.Config(), *vmConfig), vmError, nil
}

func (b *EthAPIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
Expand Down
8 changes: 3 additions & 5 deletions eth/api_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/core/state"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/internal/ethapi"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/XinFinOrg/XDPoSChain/rlp"
"github.com/XinFinOrg/XDPoSChain/rpc"
"github.com/XinFinOrg/XDPoSChain/trie"
Expand All @@ -36,14 +35,13 @@ import (
// DebugAPI is the collection of Ethereum full node APIs exposed over
// the private debugging endpoint.
type DebugAPI struct {
config *params.ChainConfig
eth *Ethereum
eth *Ethereum
}

// NewDebugAPI creates a new API definition for the full node-related
// private debug methods of the Ethereum service.
func NewDebugAPI(config *params.ChainConfig, eth *Ethereum) *DebugAPI {
return &DebugAPI{config: config, eth: eth}
func NewDebugAPI(eth *Ethereum) *DebugAPI {
return &DebugAPI{eth: eth}
}

// DumpBlock retrieves the entire state of the database at a given block.
Expand Down
16 changes: 7 additions & 9 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ import (

// Ethereum implements the Ethereum full node service.
type Ethereum struct {
config *ethconfig.Config
chainConfig *params.ChainConfig
config *ethconfig.Config

// Channel for shutting down the service
shutdownChan chan bool // Channel for shutting down the ethereum
Expand Down Expand Up @@ -146,7 +145,6 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
eth := &Ethereum{
config: config,
chainDb: chainDb,
chainConfig: chainConfig,
eventMux: stack.EventMux(),
accountManager: stack.AccountManager(),
engine: CreateConsensusEngine(stack, chainConfig, chainDb),
Expand Down Expand Up @@ -221,7 +219,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
}
vmConfig.Tracer = t
}
if eth.chainConfig.XDPoS != nil {
if chainConfig.XDPoS != nil {
c := eth.engine.(*XDPoS.XDPoS)
c.GetXDCXService = func() utils.TradingService {
return eth.XDCX
Expand Down Expand Up @@ -285,7 +283,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))

var xdPoS *XDPoS.XDPoS = nil
if eth.chainConfig.XDPoS != nil {
if chainConfig.XDPoS != nil {
xdPoS = eth.engine.(*XDPoS.XDPoS)
}
eth.APIBackend = &EthAPIBackend{
Expand All @@ -303,7 +301,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
// Set global ipc endpoint.
eth.blockchain.IPCEndpoint = stack.IPCEndpoint()

if eth.chainConfig.XDPoS != nil {
if chainConfig.XDPoS != nil {
c := eth.engine.(*XDPoS.XDPoS)
signHook := func(block *types.Block) error {
eb, err := eth.Etherbase()
Expand All @@ -315,7 +313,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin
if !ok {
return nil
}
if block.NumberU64()%common.MergeSignRange == 0 || !eth.chainConfig.IsTIP2019(block.Number()) {
if block.NumberU64()%common.MergeSignRange == 0 || !chainConfig.IsTIP2019(block.Number()) {
if err := contracts.CreateTransactionSign(chainConfig, eth.txPool, eth.accountManager, block, chainDb, eb); err != nil {
return fmt.Errorf("fail to create tx sign for importing block: %v", err)
}
Expand Down Expand Up @@ -433,7 +431,7 @@ func (e *Ethereum) APIs() []rpc.API {
Service: NewAdminAPI(e),
}, {
Namespace: "debug",
Service: NewDebugAPI(e.chainConfig, e),
Service: NewDebugAPI(e),
}, {
Namespace: "net",
Service: e.netRPCService,
Expand Down Expand Up @@ -483,7 +481,7 @@ func (e *Ethereum) ValidateMasternode() (bool, error) {
if err != nil {
return false, err
}
if e.chainConfig.XDPoS != nil {
if e.blockchain.Config().XDPoS != nil {
//check if miner's wallet is in set of validators
c := e.engine.(*XDPoS.XDPoS)

Expand Down
Loading