mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-13 13:00:10 +00:00

* [NOD-1517] Properly initialize consensus with Genesis block * [NOD-1517] Remove redundant AddHeaderTip * [NOD-1517] Don't return nil from dbHash<->DomainHash converters * [NOD-1517] Use pointer receivers * [NOD-1517] Use domain block in dagParams * [NOD-1517] Remove boolean from SelectedTip * [NOD-1517] Rename hasHeader to isHeadersOnlyBlock * [NOD-1517] Add comment * [NOD-1517] Change genesis version * [NOD-1517] Rename TestNewFactory->TestNewConsensus
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package consensusstatestore
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/dbkeys"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
|
|
)
|
|
|
|
var virtualDiffParentsKey = dbkeys.MakeBucket().Key([]byte("virtual-diff-parents"))
|
|
|
|
func (c *consensusStateStore) VirtualDiffParents(dbContext model.DBReader) ([]*externalapi.DomainHash, error) {
|
|
if c.stagedVirtualDiffParents != nil {
|
|
return c.stagedVirtualDiffParents, nil
|
|
}
|
|
|
|
virtualDiffParentsBytes, err := dbContext.Get(virtualDiffParentsKey)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return hashes.DeserializeHashSlice(virtualDiffParentsBytes)
|
|
}
|
|
|
|
func (c *consensusStateStore) StageVirtualDiffParents(tipHashes []*externalapi.DomainHash) {
|
|
c.stagedVirtualDiffParents = tipHashes
|
|
}
|
|
|
|
func (c *consensusStateStore) commitVirtualDiffParents(dbTx model.DBTransaction) error {
|
|
virtualDiffParentsBytes := hashes.SerializeHashSlice(c.stagedVirtualDiffParents)
|
|
|
|
err := dbTx.Put(virtualDiffParentsKey, virtualDiffParentsBytes)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|