mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
27 lines
604 B
Go
27 lines
604 B
Go
package doublylinkedtree
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
|
)
|
|
|
|
// LastRoot returns the last canonical block root in the given epoch
|
|
func (f *ForkChoice) LastRoot(epoch primitives.Epoch) [32]byte {
|
|
head := f.store.headNode
|
|
headEpoch := slots.ToEpoch(head.slot)
|
|
epochEnd, err := slots.EpochEnd(epoch)
|
|
if err != nil {
|
|
return [32]byte{}
|
|
}
|
|
if headEpoch <= epoch {
|
|
return head.root
|
|
}
|
|
for head != nil && head.slot > epochEnd {
|
|
head = head.parent
|
|
}
|
|
if head == nil {
|
|
return [32]byte{}
|
|
}
|
|
return head.root
|
|
}
|