mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Slightly improve the performance of antiPastHashesBetween. (#1312)
This commit is contained in:
parent
d91afbfe3b
commit
48278bd1c0
@ -42,7 +42,7 @@ func (flow *handleRequestBlocksFlow) start() error {
|
||||
// We expect that if the other peer did not receive all the headers
|
||||
// they requested, they'd re-request a block locator and re-request
|
||||
// headers with a higher lowHash
|
||||
const maxBlueScoreDifference = 1 << 12
|
||||
const maxBlueScoreDifference = 1 << 10
|
||||
blockHashes, err := flow.Domain().Consensus().GetHashesBetween(lowHash, highHash, maxBlueScoreDifference)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -35,13 +35,19 @@ func (sm *syncManager) antiPastHashesBetween(lowHash, highHash *externalapi.Doma
|
||||
// Using blueScore as an approximation is considered to be
|
||||
// fairly accurate because we presume that most DAG blocks are
|
||||
// blue.
|
||||
for highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore()+1 > maxBlueScoreDifference {
|
||||
highHash = highBlockGHOSTDAGData.SelectedParent()
|
||||
var err error
|
||||
iterator, err := sm.dagTraversalManager.SelectedChildIterator(highHash, lowHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for iterator.Next() {
|
||||
highHash = iterator.Get()
|
||||
highBlockGHOSTDAGData, err = sm.ghostdagDataStore.Get(sm.databaseContext, highHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore()+1 > maxBlueScoreDifference {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user