[NOD-694] Fix requesting blocks that will surely be orphaned during netsync. (#630)

This commit is contained in:
stasatdaglabs 2020-02-18 12:12:34 +02:00 committed by GitHub
parent 243b4b8021
commit e405dd5981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -414,12 +414,12 @@ func (sm *SyncManager) handleTxMsg(tmsg *txMsg) {
// current returns true if we believe we are synced with our peers, false if we
// still have blocks to check
//
// We consider ourselves current iff at least one of the following is true:
// We consider ourselves current iff both of the following are true:
// 1. there's no syncPeer, a.k.a. all connected peers are at the same tip
// 2. the DAG considers itself current - to prevent attacks where a peer sends an
// unknown tip but never lets us sync to it.
func (sm *SyncManager) current() bool {
return sm.syncPeer == nil || sm.dag.IsCurrent()
return sm.syncPeer == nil && sm.dag.IsCurrent()
}
// restartSyncIfNeeded finds a new sync candidate if we're not expecting any

View File

@ -109,7 +109,7 @@ func handleGetBlockTemplate(s *Server, cmd interface{}, closeChan <-chan struct{
// we have nothing besides the genesis block (blueScore == 0),
// because in that state IsCurrent may still return true.
currentBlueScore := s.cfg.DAG.SelectedTipBlueScore()
if (currentBlueScore != 0 && !s.cfg.SyncMgr.IsCurrent()) ||
if (currentBlueScore != 0 && !s.cfg.DAG.IsCurrent()) ||
(currentBlueScore == 0 && !s.cfg.shouldMineOnGenesis()) {
return nil, &rpcmodel.RPCError{
Code: rpcmodel.ErrRPCClientInInitialDownload,