mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-01 19:56:45 +00:00

* Add VirtualUTXODiff and VirtualParents to block insertion result * Add GetVirtualUTXOs * Add OnPruningPointUTXOSetOverrideHandler * Add recovery to UTXO index * Add UTXO set override notification * Fix compilation error * Fix iterators in UTXO index and fix TestUTXOIndex * Change Dialing to DEBUG * Change LogBlock location * Rename StopNotify to StopNotifying * Add sanity check * Add comment * Remove receiver from serialization functions Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
40 lines
966 B
Go
40 lines
966 B
Go
package serialization
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/utxo"
|
|
)
|
|
|
|
// UTXODiffToDBUTXODiff converts UTXODiff to DbUtxoDiff
|
|
func UTXODiffToDBUTXODiff(diff externalapi.UTXODiff) (*DbUtxoDiff, error) {
|
|
toAdd, err := utxoCollectionToDBUTXOCollection(diff.ToAdd())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
toRemove, err := utxoCollectionToDBUTXOCollection(diff.ToRemove())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &DbUtxoDiff{
|
|
ToAdd: toAdd,
|
|
ToRemove: toRemove,
|
|
}, nil
|
|
}
|
|
|
|
// DBUTXODiffToUTXODiff converts DbUtxoDiff to UTXODiff
|
|
func DBUTXODiffToUTXODiff(diff *DbUtxoDiff) (externalapi.UTXODiff, error) {
|
|
toAdd, err := dbUTXOCollectionToUTXOCollection(diff.ToAdd)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
toRemove, err := dbUTXOCollectionToUTXOCollection(diff.ToRemove)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return utxo.NewUTXODiffFromCollections(toAdd, toRemove)
|
|
}
|