mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-23 23:36:56 +00:00

* [NOD-1493] Implement serialization in data stores * [NOD-1493] Remove redundant functions * [NOD-1493] Use bluesAnticoneSizesToDBBluesAnticoneSizes inside BlockGHOSTDAGDataToDBBlockGHOSTDAGData
32 lines
997 B
Go
32 lines
997 B
Go
package serialization
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
)
|
|
|
|
func reachablityTreeNodeToDBReachablityTreeNode(reachabilityTreeNode *model.ReachabilityTreeNode) *DbReachabilityTreeNode {
|
|
return &DbReachabilityTreeNode{
|
|
Children: DomainHashesToDbHashes(reachabilityTreeNode.Children),
|
|
Parent: DomainHashToDbHash(reachabilityTreeNode.Parent),
|
|
Interval: reachablityIntervalToDBReachablityInterval(reachabilityTreeNode.Interval),
|
|
}
|
|
}
|
|
|
|
func dbReachablityTreeNodeToReachablityTreeNode(dbReachabilityTreeNode *DbReachabilityTreeNode) (*model.ReachabilityTreeNode, error) {
|
|
children, err := DbHashesToDomainHashes(dbReachabilityTreeNode.Children)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
parent, err := DbHashToDomainHash(dbReachabilityTreeNode.Parent)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &model.ReachabilityTreeNode{
|
|
Children: children,
|
|
Parent: parent,
|
|
Interval: dbReachablityIntervalToReachablityInterval(dbReachabilityTreeNode.Interval),
|
|
}, nil
|
|
}
|