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

Commit

Permalink
fix(miner): Do not use pending block for now (#1255)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear authored Oct 30, 2023
1 parent 7dd6df9 commit 9c25a75
Showing 1 changed file with 20 additions and 9 deletions.
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

0 comments on commit 9c25a75

Please sign in to comment.