Chain info: Return err if checkpoint is nil (#10729)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terencechain
2022-05-20 11:41:33 -07:00
committed by GitHub
parent 76f6d74b83
commit 370cf1a6c8
31 changed files with 365 additions and 177 deletions

View File

@@ -210,8 +210,11 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
if len(roots) == 0 {
return nil
}
_, bestPeers := s.cfg.p2p.Peers().BestFinalized(maxPeerRequest, s.cfg.chain.FinalizedCheckpt().Epoch)
cp, err := s.cfg.chain.FinalizedCheckpt()
if err != nil {
return err
}
_, bestPeers := s.cfg.p2p.Peers().BestFinalized(maxPeerRequest, cp.Epoch)
if len(bestPeers) == 0 {
return nil
}
@@ -272,7 +275,11 @@ func (s *Service) validatePendingSlots() error {
defer s.pendingQueueLock.Unlock()
oldBlockRoots := make(map[[32]byte]bool)
finalizedEpoch := s.cfg.chain.FinalizedCheckpt().Epoch
cp, err := s.cfg.chain.FinalizedCheckpt()
if err != nil {
return err
}
finalizedEpoch := cp.Epoch
if s.slotToPendingBlocks == nil {
return errors.New("slotToPendingBlocks cache can't be nil")
}