mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 22:13:47 +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
|
// GetCurrentSpan get current span from contract
|
||||||
func (c *Bor) GetCurrentSpan(snapshotNumber uint64) (*Span, error) {
|
func (c *Bor) GetCurrentSpan(headerHash common.Hash) (*Span, error) {
|
||||||
// block
|
// block
|
||||||
blockNr := rpc.BlockNumber(snapshotNumber)
|
blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false)
|
||||||
|
|
||||||
// method
|
// method
|
||||||
method := "getCurrentSpan"
|
method := "getCurrentSpan"
|
||||||
|
|
@ -866,7 +866,7 @@ func (c *Bor) GetCurrentSpan(snapshotNumber uint64) (*Span, error) {
|
||||||
Gas: &gas,
|
Gas: &gas,
|
||||||
To: &toAddress,
|
To: &toAddress,
|
||||||
Data: &msgData,
|
Data: &msgData,
|
||||||
}, rpc.BlockNumberOrHash{BlockNumber: &blockNr}, nil)
|
}, blockNr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -949,7 +949,7 @@ func (c *Bor) checkAndCommitSpan(
|
||||||
chain core.ChainContext,
|
chain core.ChainContext,
|
||||||
) error {
|
) error {
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
span, err := c.GetCurrentSpan(headerNumber - 1)
|
span, err := c.GetCurrentSpan(header.ParentHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -1167,7 +1167,7 @@ func (c *Bor) getNextHeimdallSpanForTest(
|
||||||
chain core.ChainContext,
|
chain core.ChainContext,
|
||||||
) (*HeimdallSpan, error) {
|
) (*HeimdallSpan, error) {
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
span, err := c.GetCurrentSpan(headerNumber - 1)
|
span, err := c.GetCurrentSpan(header.ParentHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue