mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 15:02:32 +00:00
[NOD-694] Fix requesting blocks that will surely be orphaned during netsync. (#630)
This commit is contained in:
parent
243b4b8021
commit
e405dd5981
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user