Skip to content

Commit

Permalink
bugfix: Returning error if block is nil, and set before send chain head
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed May 18, 2023
1 parent bd3d256 commit 45f2355
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ func (sl *Slice) Append(header *types.Header, domPendingHeader *types.Header, do
}
if subReorg {
block.SetAppendTime(appendFinished)
sl.hc.chainHeadFeed.Send(ChainHeadEvent{Block: block})
sl.hc.SetCurrentHeader(block.Header())
sl.hc.chainHeadFeed.Send(ChainHeadEvent{Block: block})
}

// Relay the new pendingHeader
Expand Down
6 changes: 5 additions & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ func (b *QuaiAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumb
if number == rpc.LatestBlockNumber {
return b.eth.core.CurrentBlock(), nil
}
return b.eth.core.GetBlockByNumber(uint64(number)), nil
block := b.eth.core.GetBlockByNumber(uint64(number))
if block != nil {
return block, nil
}
return nil, errors.New("block is nil api backend")
}

func (b *QuaiAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
Expand Down

0 comments on commit 45f2355

Please sign in to comment.