Merge pull request #5540 from austinabell/austin/beyondmaxio

Remove unnecessary database reads in validation check
This commit is contained in:
Łukasz Magiera 2021-02-05 22:40:32 +01:00 committed by GitHub
commit 9f546c2d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1791,11 +1791,10 @@ func (syncer *Syncer) getLatestBeaconEntry(_ context.Context, ts *types.TipSet)
}
func (syncer *Syncer) IsEpochBeyondCurrMax(epoch abi.ChainEpoch) bool {
g, err := syncer.store.GetGenesis()
if err != nil {
if syncer.Genesis == nil {
return false
}
now := uint64(build.Clock.Now().Unix())
return epoch > (abi.ChainEpoch((now-g.Timestamp)/build.BlockDelaySecs) + MaxHeightDrift)
return epoch > (abi.ChainEpoch((now-syncer.Genesis.MinTimestamp())/build.BlockDelaySecs) + MaxHeightDrift)
}