mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix: use hash instead of block number incase of reorg
This commit is contained in:
parent
34c3457c07
commit
264551cbc1
1 changed files with 5 additions and 5 deletions
|
|
@ -846,9 +846,9 @@ func (c *Bor) Close() error {
|
|||
}
|
||||
|
||||
// GetCurrentSpan get current span from contract
|
||||
func (c *Bor) GetCurrentSpan(snapshotNumber uint64) (*Span, error) {
|
||||
func (c *Bor) GetCurrentSpan(headerHash common.Hash) (*Span, error) {
|
||||
// block
|
||||
blockNr := rpc.BlockNumber(snapshotNumber)
|
||||
blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false)
|
||||
|
||||
// method
|
||||
method := "getCurrentSpan"
|
||||
|
|
@ -866,7 +866,7 @@ func (c *Bor) GetCurrentSpan(snapshotNumber uint64) (*Span, error) {
|
|||
Gas: &gas,
|
||||
To: &toAddress,
|
||||
Data: &msgData,
|
||||
}, rpc.BlockNumberOrHash{BlockNumber: &blockNr}, nil)
|
||||
}, blockNr, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -949,7 +949,7 @@ func (c *Bor) checkAndCommitSpan(
|
|||
chain core.ChainContext,
|
||||
) error {
|
||||
headerNumber := header.Number.Uint64()
|
||||
span, err := c.GetCurrentSpan(headerNumber - 1)
|
||||
span, err := c.GetCurrentSpan(header.ParentHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1167,7 +1167,7 @@ func (c *Bor) getNextHeimdallSpanForTest(
|
|||
chain core.ChainContext,
|
||||
) (*HeimdallSpan, error) {
|
||||
headerNumber := header.Number.Uint64()
|
||||
span, err := c.GetCurrentSpan(headerNumber - 1)
|
||||
span, err := c.GetCurrentSpan(header.ParentHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue