mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 14:46:44 +00:00
[NOD-874] If the node is not current call sm.restartSyncIfNeeded() on handleInvMsg (#684)
* [NOD-874] If the node is not current call sm.restartSyncIfNeeded() on handleInvMsg * [NOD-874] Check haveUnknownInvBlock before restartSyncIfNeeded * [NOD-874] Fix comment * [NOD-874] Fix comment * [NOD-874] Fix comment
This commit is contained in:
parent
36d866375e
commit
b20a7a679b
@ -650,6 +650,8 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haveUnknownInvBlock := false
|
||||||
|
|
||||||
// Request the advertised inventory if we don't already have it. Also,
|
// Request the advertised inventory if we don't already have it. Also,
|
||||||
// request parent blocks of orphans if we receive one we already have.
|
// request parent blocks of orphans if we receive one we already have.
|
||||||
// Finally, attempt to detect potential stalls due to big orphan DAGs
|
// Finally, attempt to detect potential stalls due to big orphan DAGs
|
||||||
@ -689,6 +691,10 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if iv.Type == wire.InvTypeBlock {
|
||||||
|
haveUnknownInvBlock = true
|
||||||
|
}
|
||||||
|
|
||||||
// Add it to the request queue.
|
// Add it to the request queue.
|
||||||
state.addInvToRequestQueue(iv)
|
state.addInvToRequestQueue(iv)
|
||||||
continue
|
continue
|
||||||
@ -733,6 +739,13 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to send invs from queue: %s", err)
|
log.Errorf("Failed to send invs from queue: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if haveUnknownInvBlock && !sm.current() {
|
||||||
|
// If one of the inv messages is an unknown block
|
||||||
|
// it is an indication that one of our peers has more
|
||||||
|
// up-to-date data than us.
|
||||||
|
sm.restartSyncIfNeeded()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *SyncManager) addInvsToGetDataMessageFromQueue(gdmsg *wire.MsgGetData, state *peerSyncState, invType wire.InvType, maxInvsToAdd int) error {
|
func (sm *SyncManager) addInvsToGetDataMessageFromQueue(gdmsg *wire.MsgGetData, state *peerSyncState, invType wire.InvType, maxInvsToAdd int) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user