mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/catalyst: dry
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
e3bb4044bd
commit
998cec05af
1 changed files with 12 additions and 12 deletions
|
|
@ -145,13 +145,8 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal) error {
|
||||||
c.feeRecipientLock.Unlock()
|
c.feeRecipientLock.Unlock()
|
||||||
|
|
||||||
// Reset to CurrentBlock in case of the chain was rewound
|
// Reset to CurrentBlock in case of the chain was rewound
|
||||||
block := c.eth.BlockChain().CurrentBlock()
|
if headerHash := c.eth.BlockChain().CurrentBlock().Hash(); c.curForkchoiceState.HeadBlockHash != headerHash {
|
||||||
if c.curForkchoiceState.HeadBlockHash != block.Hash() {
|
c.setCurrentState(headerHash, headerHash)
|
||||||
c.curForkchoiceState = engine.ForkchoiceStateV1{
|
|
||||||
HeadBlockHash: block.Hash(),
|
|
||||||
SafeBlockHash: block.Hash(),
|
|
||||||
FinalizedBlockHash: block.Hash(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fcResponse, err := c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, &engine.PayloadAttributes{
|
fcResponse, err := c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, &engine.PayloadAttributes{
|
||||||
|
|
@ -190,11 +185,7 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal) error {
|
||||||
if _, err = c.engineAPI.NewPayloadV2(*payload); err != nil {
|
if _, err = c.engineAPI.NewPayloadV2(*payload); err != nil {
|
||||||
return fmt.Errorf("failed to mark payload as canonical: %v", err)
|
return fmt.Errorf("failed to mark payload as canonical: %v", err)
|
||||||
}
|
}
|
||||||
c.curForkchoiceState = engine.ForkchoiceStateV1{
|
c.setCurrentState(payload.BlockHash, finalizedHash)
|
||||||
HeadBlockHash: payload.BlockHash,
|
|
||||||
SafeBlockHash: payload.BlockHash,
|
|
||||||
FinalizedBlockHash: finalizedHash,
|
|
||||||
}
|
|
||||||
// Mark the block containing the payload as canonical
|
// Mark the block containing the payload as canonical
|
||||||
if _, err = c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, nil); err != nil {
|
if _, err = c.engineAPI.ForkchoiceUpdatedV2(c.curForkchoiceState, nil); err != nil {
|
||||||
return fmt.Errorf("failed to mark block as canonical: %v", err)
|
return fmt.Errorf("failed to mark block as canonical: %v", err)
|
||||||
|
|
@ -249,6 +240,15 @@ func (c *SimulatedBeacon) loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setCurrentState sets the current forkchoice state
|
||||||
|
func (c *SimulatedBeacon) setCurrentState(headHash, finalizedHash common.Hash) {
|
||||||
|
c.curForkchoiceState = engine.ForkchoiceStateV1{
|
||||||
|
HeadBlockHash: headHash,
|
||||||
|
SafeBlockHash: headHash,
|
||||||
|
FinalizedBlockHash: finalizedHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) {
|
func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) {
|
||||||
stack.RegisterAPIs([]rpc.API{
|
stack.RegisterAPIs([]rpc.API{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue