mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-24 07:46:45 +00:00

* Replace blueScore with blueWork in ghostDAG SelectedParent selection * Add blueWork to protopuf ghostdag data * Auto generate protobuf go code * Serialize/Deserialize blueWork when converting to protobuf * pass block header store to ghostdagmanager * Convert tal's ghostdag2 implementation to blueWork * Change finality test to check the blueWork instead of blueScore * Update ghostdag_test to pass blockHeaderStore to ghostdag, and test all networks genesis headers * Add sanity blueWork check to ghostdag_test
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package ghostdagmanager
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"math/big"
|
|
)
|
|
|
|
type blockGHOSTDAGData struct {
|
|
blueScore uint64
|
|
blueWork *big.Int
|
|
selectedParent *externalapi.DomainHash
|
|
mergeSetBlues []*externalapi.DomainHash
|
|
mergeSetReds []*externalapi.DomainHash
|
|
bluesAnticoneSizes map[externalapi.DomainHash]model.KType
|
|
}
|
|
|
|
// NewBlockGHOSTDAGData creates a new instance of model.BlockGHOSTDAGData
|
|
func NewBlockGHOSTDAGData(
|
|
blueScore uint64,
|
|
blueWork *big.Int,
|
|
selectedParent *externalapi.DomainHash,
|
|
mergeSetBlues []*externalapi.DomainHash,
|
|
mergeSetReds []*externalapi.DomainHash,
|
|
bluesAnticoneSizes map[externalapi.DomainHash]model.KType) model.BlockGHOSTDAGData {
|
|
|
|
return &blockGHOSTDAGData{
|
|
blueScore: blueScore,
|
|
blueWork: blueWork,
|
|
selectedParent: selectedParent,
|
|
mergeSetBlues: mergeSetBlues,
|
|
mergeSetReds: mergeSetReds,
|
|
bluesAnticoneSizes: bluesAnticoneSizes,
|
|
}
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) BlueScore() uint64 {
|
|
return bgd.blueScore
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) BlueWork() *big.Int {
|
|
return bgd.blueWork
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) SelectedParent() *externalapi.DomainHash {
|
|
return bgd.selectedParent
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) MergeSetBlues() []*externalapi.DomainHash {
|
|
return bgd.mergeSetBlues
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) MergeSetReds() []*externalapi.DomainHash {
|
|
return bgd.mergeSetReds
|
|
}
|
|
|
|
func (bgd *blockGHOSTDAGData) BluesAnticoneSizes() map[externalapi.DomainHash]model.KType {
|
|
return bgd.bluesAnticoneSizes
|
|
}
|