mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 14:46:44 +00:00
[NOD-1565] Reorder getSyncInfo in a way that won't unnecessarily call HeaderTipsPruningPoint. (#1146)
This commit is contained in:
parent
2096a28d1c
commit
d65f382c80
@ -57,6 +57,14 @@ func (sm *syncManager) resolveSyncState() (externalapi.SyncState, error) {
|
|||||||
return externalapi.SyncStateHeadersFirst, nil
|
return externalapi.SyncStateHeadersFirst, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtualSelectedParentHash, err := sm.virtualSelectedParentHash()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if *virtualSelectedParentHash == *headerVirtualSelectedParentHash {
|
||||||
|
return externalapi.SyncStateRelay, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Once the header tips are synced, check the status of
|
// Once the header tips are synced, check the status of
|
||||||
// the pruning point from the point of view of the header
|
// the pruning point from the point of view of the header
|
||||||
// tips. We check it against StatusValid (rather than
|
// tips. We check it against StatusValid (rather than
|
||||||
@ -75,15 +83,7 @@ func (sm *syncManager) resolveSyncState() (externalapi.SyncState, error) {
|
|||||||
return externalapi.SyncStateMissingUTXOSet, nil
|
return externalapi.SyncStateMissingUTXOSet, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
virtualSelectedParentHash, err := sm.virtualSelectedParentHash()
|
return externalapi.SyncStateMissingBlockBodies, nil
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
if *virtualSelectedParentHash != *headerVirtualSelectedParentHash {
|
|
||||||
return externalapi.SyncStateMissingBlockBodies, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return externalapi.SyncStateRelay, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *syncManager) virtualSelectedParentHash() (*externalapi.DomainHash, error) {
|
func (sm *syncManager) virtualSelectedParentHash() (*externalapi.DomainHash, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user