2023-12-22 10:44:55 +00:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
2024-01-16 08:23:02 +00:00
|
|
|
"github.com/ledgerwatch/erigon/polygon/heimdall"
|
2023-12-22 10:44:55 +00:00
|
|
|
)
|
|
|
|
|
2024-01-16 08:23:02 +00:00
|
|
|
func statePointFromCheckpoint(checkpoint *heimdall.Checkpoint) *statePoint {
|
2023-12-22 10:44:55 +00:00
|
|
|
return &statePoint{
|
|
|
|
proposer: checkpoint.Proposer,
|
|
|
|
startBlock: new(big.Int).Set(checkpoint.StartBlock),
|
|
|
|
endBlock: new(big.Int).Set(checkpoint.EndBlock),
|
|
|
|
rootHash: checkpoint.RootHash,
|
|
|
|
chainId: checkpoint.BorChainID,
|
|
|
|
timestamp: checkpoint.Timestamp,
|
|
|
|
kind: checkpointKind,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-16 08:23:02 +00:00
|
|
|
func statePointFromMilestone(milestone *heimdall.Milestone) *statePoint {
|
2023-12-22 10:44:55 +00:00
|
|
|
return &statePoint{
|
|
|
|
proposer: milestone.Proposer,
|
|
|
|
startBlock: new(big.Int).Set(milestone.StartBlock),
|
|
|
|
endBlock: new(big.Int).Set(milestone.EndBlock),
|
|
|
|
rootHash: milestone.Hash,
|
|
|
|
chainId: milestone.BorChainID,
|
|
|
|
timestamp: milestone.Timestamp,
|
|
|
|
kind: milestoneKind,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type statePoint struct {
|
|
|
|
proposer common.Address
|
|
|
|
startBlock *big.Int
|
|
|
|
endBlock *big.Int
|
|
|
|
rootHash common.Hash
|
|
|
|
chainId string
|
|
|
|
timestamp uint64
|
|
|
|
kind statePointKind
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sp *statePoint) length() int {
|
|
|
|
return int(new(big.Int).Sub(sp.endBlock, sp.startBlock).Int64() + 1)
|
|
|
|
}
|