mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
23 lines
616 B
Go
23 lines
616 B
Go
package sync
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
|
"github.com/ledgerwatch/erigon/polygon/bor"
|
|
)
|
|
|
|
type StatePointHeadersVerifier func(statePoint *statePoint, headers []*types.Header) error
|
|
|
|
func VerifyStatePointHeaders(statePoint *statePoint, headers []*types.Header) error {
|
|
rootHash, err := bor.ComputeHeadersRootHash(headers)
|
|
if err != nil {
|
|
return fmt.Errorf("VerifyStatePointHeaders: failed to compute headers root hash %w", err)
|
|
}
|
|
if !bytes.Equal(rootHash, statePoint.rootHash[:]) {
|
|
return fmt.Errorf("VerifyStatePointHeaders: bad headers root hash")
|
|
}
|
|
return nil
|
|
}
|