fix for nil (#1950)

This commit is contained in:
Alex Sharov 2021-05-17 20:45:57 +07:00 committed by GitHub
parent af6a6abd50
commit 1770beaf9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,9 @@ func getReceipts(ctx context.Context, tx ethdb.Tx, chainConfig *params.ChainConf
}
block := rawdb.ReadBlock(tx, hash, number)
if block == nil {
return nil, nil
}
bc := adapter.NewBlockGetter(tx)
getHeader := func(hash common.Hash, number uint64) *types.Header {
@ -46,8 +49,7 @@ func getReceipts(ctx context.Context, tx ethdb.Tx, chainConfig *params.ChainConf
for i, txn := range block.Transactions() {
ibs.Prepare(txn.Hash(), block.Hash(), i)
header := rawdb.ReadHeader(tx, hash, number)
receipt, err := core.ApplyTransaction(chainConfig, getHeader, ethash.NewFaker(), nil, gp, ibs, state.NewNoopWriter(), header, txn, usedGas, vm.Config{})
receipt, err := core.ApplyTransaction(chainConfig, getHeader, ethash.NewFaker(), nil, gp, ibs, state.NewNoopWriter(), block.Header(), txn, usedGas, vm.Config{})
if err != nil {
return nil, err
}