mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
bor: check nil-blocks in other places (#8788)
This commit is contained in:
parent
d557679a0b
commit
f476fe690f
@ -1451,22 +1451,13 @@ func (c *Bor) GetRootHash(ctx context.Context, tx kv.Tx, start, end uint64) (str
|
||||
}
|
||||
|
||||
func (c *Bor) getHeaderByNumber(ctx context.Context, tx kv.Tx, number uint64) (*types.Header, error) {
|
||||
_, err := c.blockReader.BlockByNumber(ctx, tx, number)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header, err := c.blockReader.HeaderByNumber(ctx, tx, number)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if header == nil {
|
||||
return nil, fmt.Errorf("block header not found: %d", number)
|
||||
return nil, fmt.Errorf("[bor] header not found: %d", number)
|
||||
}
|
||||
|
||||
return header, nil
|
||||
}
|
||||
|
||||
|
@ -84,11 +84,16 @@ func borVerify(ctx context.Context, config *config, start uint64, end uint64, ha
|
||||
}
|
||||
} else {
|
||||
// in case of milestone(isCheckpoint==false) get the hash of endBlock
|
||||
block, err := config.blockReader.BlockByNumber(context.Background(), roTx, end)
|
||||
block, err := config.blockReader.BlockByNumber(ctx, roTx, end)
|
||||
if err != nil {
|
||||
log.Debug("[bor] Failed to get end block hash while whitelisting milestone", "number", end, "err", err)
|
||||
return hash, errEndBlock
|
||||
}
|
||||
if block == nil {
|
||||
err := fmt.Errorf("[bor] block not found: %d", end)
|
||||
log.Debug("[bor] Failed to get end block hash while whitelisting milestone", "number", end, "err", err)
|
||||
return hash, err
|
||||
}
|
||||
|
||||
localHash = fmt.Sprintf("%v", block.Hash())[2:]
|
||||
}
|
||||
@ -135,7 +140,7 @@ func borVerify(ctx context.Context, config *config, start uint64, end uint64, ha
|
||||
}
|
||||
|
||||
// fetch the end block hash
|
||||
block, err := config.blockReader.BlockByNumber(context.Background(), roTx, end)
|
||||
block, err := config.blockReader.BlockByNumber(ctx, roTx, end)
|
||||
if err != nil {
|
||||
log.Debug("[bor] Failed to get end block hash while whitelisting", "err", err)
|
||||
return hash, errEndBlock
|
||||
|
Loading…
Reference in New Issue
Block a user