Add Unsafe Sync (#4906)

* add unsafe flag

* imports

* Use finalized epoch

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
Nishant Das
2020-02-19 16:25:07 +08:00
committed by GitHub
parent 4389e9d3c9
commit 44856f9500
6 changed files with 31 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ type blockchainService interface {
blockchain.BlockReceiver
blockchain.HeadFetcher
ClearCachedStates()
blockchain.FinalizationFetcher
}
const (
@@ -178,7 +179,7 @@ func (s *Service) waitForMinimumPeers() {
required = flags.Get().MinimumSyncPeers
}
for {
_, _, peers := s.p2p.Peers().BestFinalized(params.BeaconConfig().MaxPeersToSync, helpers.SlotToEpoch(s.chain.HeadSlot()))
_, _, peers := s.p2p.Peers().BestFinalized(params.BeaconConfig().MaxPeersToSync, s.chain.FinalizedCheckpt().Epoch)
if len(peers) >= required {
break
}