forked from cerc-io/plugeth
eth: remove check for tdd reached on pos api block tags (#27799)
This change defers to the blockchain for in what circumstances to return error, instead of handling many error-cases in the api backend.
This commit is contained in:
parent
3ff6b3c31e
commit
3a662d4735
@ -78,24 +78,18 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb
|
|||||||
return b.eth.blockchain.CurrentBlock(), nil
|
return b.eth.blockchain.CurrentBlock(), nil
|
||||||
}
|
}
|
||||||
if number == rpc.FinalizedBlockNumber {
|
if number == rpc.FinalizedBlockNumber {
|
||||||
if !b.eth.Merger().TDDReached() {
|
|
||||||
return nil, errors.New("'finalized' tag not supported on pre-merge network")
|
|
||||||
}
|
|
||||||
block := b.eth.blockchain.CurrentFinalBlock()
|
block := b.eth.blockchain.CurrentFinalBlock()
|
||||||
if block != nil {
|
if block == nil {
|
||||||
return block, nil
|
return nil, errors.New("finalized block not found")
|
||||||
}
|
}
|
||||||
return nil, errors.New("finalized block not found")
|
return block, nil
|
||||||
}
|
}
|
||||||
if number == rpc.SafeBlockNumber {
|
if number == rpc.SafeBlockNumber {
|
||||||
if !b.eth.Merger().TDDReached() {
|
|
||||||
return nil, errors.New("'safe' tag not supported on pre-merge network")
|
|
||||||
}
|
|
||||||
block := b.eth.blockchain.CurrentSafeBlock()
|
block := b.eth.blockchain.CurrentSafeBlock()
|
||||||
if block != nil {
|
if block == nil {
|
||||||
return block, nil
|
return nil, errors.New("safe block not found")
|
||||||
}
|
}
|
||||||
return nil, errors.New("safe block not found")
|
return block, nil
|
||||||
}
|
}
|
||||||
return b.eth.blockchain.GetHeaderByNumber(uint64(number)), nil
|
return b.eth.blockchain.GetHeaderByNumber(uint64(number)), nil
|
||||||
}
|
}
|
||||||
@ -136,9 +130,6 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
|
|||||||
return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
|
return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
|
||||||
}
|
}
|
||||||
if number == rpc.FinalizedBlockNumber {
|
if number == rpc.FinalizedBlockNumber {
|
||||||
if !b.eth.Merger().TDDReached() {
|
|
||||||
return nil, errors.New("'finalized' tag not supported on pre-merge network")
|
|
||||||
}
|
|
||||||
header := b.eth.blockchain.CurrentFinalBlock()
|
header := b.eth.blockchain.CurrentFinalBlock()
|
||||||
if header == nil {
|
if header == nil {
|
||||||
return nil, errors.New("finalized block not found")
|
return nil, errors.New("finalized block not found")
|
||||||
@ -146,9 +137,6 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
|
|||||||
return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
|
return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
|
||||||
}
|
}
|
||||||
if number == rpc.SafeBlockNumber {
|
if number == rpc.SafeBlockNumber {
|
||||||
if !b.eth.Merger().TDDReached() {
|
|
||||||
return nil, errors.New("'safe' tag not supported on pre-merge network")
|
|
||||||
}
|
|
||||||
header := b.eth.blockchain.CurrentSafeBlock()
|
header := b.eth.blockchain.CurrentSafeBlock()
|
||||||
if header == nil {
|
if header == nil {
|
||||||
return nil, errors.New("safe block not found")
|
return nil, errors.New("safe block not found")
|
||||||
|
Loading…
Reference in New Issue
Block a user