mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 14:35:53 +00:00
Fix daa score to chain block
This commit is contained in:
parent
877c46bfec
commit
6316c3c2a8
@ -772,14 +772,6 @@ func (pm *pruningManager) calculateDiffBetweenPreviousAndCurrentPruningPoints(st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//currentPruningGhostDAG, err := pm.ghostdagDataStore.Get(pm.databaseContext, stagingArea, currentPruningHash, false)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
//}
|
|
||||||
//previousPruningGhostDAG, err := pm.ghostdagDataStore.Get(pm.databaseContext, stagingArea, previousPruningHash, false)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
//}
|
|
||||||
|
|
||||||
utxoDiff := utxo.NewMutableUTXODiff()
|
utxoDiff := utxo.NewMutableUTXODiff()
|
||||||
|
|
||||||
@ -798,14 +790,14 @@ func (pm *pruningManager) calculateDiffBetweenPreviousAndCurrentPruningPoints(st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
chainBlockHeader, err := pm.blockHeaderStore.BlockHeader(pm.databaseContext, stagingArea, child)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
for _, blockAcceptanceData := range chainBlockAcceptanceData {
|
for _, blockAcceptanceData := range chainBlockAcceptanceData {
|
||||||
blockHeader, err := pm.blockHeaderStore.BlockHeader(pm.databaseContext, stagingArea, blockAcceptanceData.BlockHash)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData {
|
for _, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData {
|
||||||
if transactionAcceptanceData.IsAccepted {
|
if transactionAcceptanceData.IsAccepted {
|
||||||
err = utxoDiff.AddTransaction(transactionAcceptanceData.Transaction, blockHeader.DAAScore())
|
err = utxoDiff.AddTransaction(transactionAcceptanceData.Transaction, chainBlockHeader.DAAScore())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -813,71 +805,8 @@ func (pm *pruningManager) calculateDiffBetweenPreviousAndCurrentPruningPoints(st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return utxoDiff.ToImmutable(), nil
|
|
||||||
|
|
||||||
//currentPruningCurrentDiffChild := currentPruningHash
|
return utxoDiff.ToImmutable(), err
|
||||||
//previousPruningCurrentDiffChild := previousPruningHash
|
|
||||||
//// We need to use BlueWork because it's the only thing that's monotonic in the whole DAG
|
|
||||||
//// We use the BlueWork to know which point is currently lower on the DAG so we can keep climbing its children,
|
|
||||||
//// that way we keep climbing on the lowest point until they both reach the exact same descendant
|
|
||||||
//currentPruningCurrentDiffChildBlueWork := currentPruningGhostDAG.BlueWork()
|
|
||||||
//previousPruningCurrentDiffChildBlueWork := previousPruningGhostDAG.BlueWork()
|
|
||||||
//
|
|
||||||
//var diffHashesFromPrevious []*externalapi.DomainHash
|
|
||||||
//var diffHashesFromCurrent []*externalapi.DomainHash
|
|
||||||
//for {
|
|
||||||
// // if currentPruningCurrentDiffChildBlueWork > previousPruningCurrentDiffChildBlueWork
|
|
||||||
// if currentPruningCurrentDiffChildBlueWork.Cmp(previousPruningCurrentDiffChildBlueWork) == 1 {
|
|
||||||
// diffHashesFromPrevious = append(diffHashesFromPrevious, previousPruningCurrentDiffChild)
|
|
||||||
// previousPruningCurrentDiffChild, err = pm.utxoDiffStore.UTXODiffChild(pm.databaseContext, stagingArea, previousPruningCurrentDiffChild)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// diffChildGhostDag, err := pm.ghostdagDataStore.Get(pm.databaseContext, stagingArea, previousPruningCurrentDiffChild, false)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// previousPruningCurrentDiffChildBlueWork = diffChildGhostDag.BlueWork()
|
|
||||||
// } else if currentPruningCurrentDiffChild.Equal(previousPruningCurrentDiffChild) {
|
|
||||||
// break
|
|
||||||
// } else {
|
|
||||||
// diffHashesFromCurrent = append(diffHashesFromCurrent, currentPruningCurrentDiffChild)
|
|
||||||
// currentPruningCurrentDiffChild, err = pm.utxoDiffStore.UTXODiffChild(pm.databaseContext, stagingArea, currentPruningCurrentDiffChild)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// diffChildGhostDag, err := pm.ghostdagDataStore.Get(pm.databaseContext, stagingArea, currentPruningCurrentDiffChild, false)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// currentPruningCurrentDiffChildBlueWork = diffChildGhostDag.BlueWork()
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//// The order in which we apply the diffs should be from top to bottom, but we traversed from bottom to top
|
|
||||||
//// so we apply the diffs in reverse order.
|
|
||||||
//oldDiff := utxo.NewMutableUTXODiff()
|
|
||||||
//for i := len(diffHashesFromPrevious) - 1; i >= 0; i-- {
|
|
||||||
// utxoDiff, err := pm.utxoDiffStore.UTXODiff(pm.databaseContext, stagingArea, diffHashesFromPrevious[i])
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// err = oldDiff.WithDiffInPlace(utxoDiff)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//newDiff := utxo.NewMutableUTXODiff()
|
|
||||||
//for i := len(diffHashesFromCurrent) - 1; i >= 0; i-- {
|
|
||||||
// utxoDiff, err := pm.utxoDiffStore.UTXODiff(pm.databaseContext, stagingArea, diffHashesFromCurrent[i])
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// err = newDiff.WithDiffInPlace(utxoDiff)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//return oldDiff.DiffFrom(newDiff.ToImmutable())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// finalityScore is the number of finality intervals passed since
|
// finalityScore is the number of finality intervals passed since
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user