Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

fix(miner): Do not use pending block for now #1255

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Changes from 2 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
29 changes: 20 additions & 9 deletions eth/polar/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ func (b *backend) BlockByNumber(_ context.Context, number rpc.BlockNumber) (*typ
// Pending block is only known by the miner
switch number {
case rpc.PendingBlockNumber:
block := b.polar.miner.PendingBlock()
return block, nil
header := b.polar.blockchain.CurrentBlock()
return b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
// block := b.polar.miner.PendingBlock()
// return block, nil
// Otherwise resolve and return the block
case rpc.LatestBlockNumber:
header := b.polar.blockchain.CurrentBlock()
Expand Down Expand Up @@ -307,16 +309,25 @@ func (b *backend) StateAndHeaderByNumber(
ctx context.Context,
number rpc.BlockNumber,
) (state.StateDB, *types.Header, error) {
var header *types.Header
// Pending state is only known by the miner
if number == rpc.PendingBlockNumber {
block, state := b.polar.miner.Pending()
return state, block.Header(), nil
}
// Otherwise resolve the block number and return its state
header, err := b.HeaderByNumber(ctx, number)
if err != nil {
return nil, nil, err
header = b.polar.blockchain.CurrentBlock()
// The above code is returning a block from the blockchain based on the given header
// hash and block
// number.
// return b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil
// block, state := b.polar.miner.Pending()
// return state, block.Header(), nil
} else {
// Otherwise resolve the block number and return its state
var err error
header, err = b.HeaderByNumber(ctx, number)
if err != nil {
return nil, nil, err
}
}

if header == nil {
// to match Geth
return nil, nil, core.ErrBlockNotFound
Expand Down
Loading