mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
eth/catalyst: remove useless constructor
This commit is contained in:
parent
a1e354b8e7
commit
f11bb4b632
4 changed files with 9 additions and 15 deletions
|
|
@ -45,9 +45,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register adds the engine API to the full node.
|
// Register adds the engine API and related APIs to the full node.
|
||||||
func Register(stack *node.Node, backend *eth.Ethereum) error {
|
func Register(stack *node.Node, backend *eth.Ethereum) error {
|
||||||
stack.RegisterAPIs([]rpc.API{
|
stack.RegisterAPIs([]rpc.API{
|
||||||
|
newTestingAPI(backend),
|
||||||
{
|
{
|
||||||
Namespace: "engine",
|
Namespace: "engine",
|
||||||
Service: NewConsensusAPI(backend),
|
Service: NewConsensusAPI(backend),
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/miner"
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,20 +34,13 @@ type TestingAPI struct {
|
||||||
eth *eth.Ethereum
|
eth *eth.Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestingAPI(eth *eth.Ethereum) *TestingAPI {
|
func newTestingAPI(backend *eth.Ethereum) rpc.API {
|
||||||
return &TestingAPI{
|
return rpc.API{
|
||||||
eth: eth,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterTestingAPI(stack *node.Node, backend *eth.Ethereum) error {
|
|
||||||
stack.RegisterAPIs([]rpc.API{{
|
|
||||||
Namespace: "testing",
|
Namespace: "testing",
|
||||||
Service: NewTestingAPI(backend),
|
Service: &TestingAPI{backend},
|
||||||
|
Version: "1.0",
|
||||||
Authenticated: false,
|
Authenticated: false,
|
||||||
},
|
}
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *TestingAPI) BuildBlockV1(parentHash common.Hash, payloadAttributes engine.PayloadAttributes, transactions *[]hexutil.Bytes, extraData *hexutil.Bytes) (*engine.ExecutionPayloadEnvelope, error) {
|
func (api *TestingAPI) BuildBlockV1(parentHash common.Hash, payloadAttributes engine.PayloadAttributes, transactions *[]hexutil.Bytes, extraData *hexutil.Bytes) (*engine.ExecutionPayloadEnvelope, error) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func TestBuildBlockV1(t *testing.T) {
|
||||||
currentNonce, _ := ethservice.APIBackend.GetPoolNonce(context.Background(), testAddr)
|
currentNonce, _ := ethservice.APIBackend.GetPoolNonce(context.Background(), testAddr)
|
||||||
tx, _ := types.SignTx(types.NewTransaction(currentNonce, testAddr, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil), types.LatestSigner(ethservice.BlockChain().Config()), testKey)
|
tx, _ := types.SignTx(types.NewTransaction(currentNonce, testAddr, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil), types.LatestSigner(ethservice.BlockChain().Config()), testKey)
|
||||||
|
|
||||||
api := NewTestingAPI(ethservice)
|
api := &TestingAPI{eth: ethservice}
|
||||||
|
|
||||||
t.Run("buildOnCurrentHead", func(t *testing.T) {
|
t.Run("buildOnCurrentHead", func(t *testing.T) {
|
||||||
envelope, err := api.BuildBlockV1(parent.Hash(), attrs, nil, nil)
|
envelope, err := api.BuildBlockV1(parent.Hash(), attrs, nil, nil)
|
||||||
|
|
|
||||||
|
|
@ -364,5 +364,6 @@ func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) {
|
||||||
Service: api,
|
Service: api,
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
},
|
},
|
||||||
|
newTestingAPI(sim.eth),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue