mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-02 12:16:43 +00:00

* [NOD-1512] Implement UTXO set deserialization * [NOD-1512] Remove redundant file * [NOD-1512] Don't use big endian for serialization * [NOD-1512] Use Read/Write element * [NOD-1512] Unexport ReadElement * [NOD-1512] Fix StageVirtualUTXOSet * [NOD-1512] Get rid of dagParams in consensusStateManager * [NOD-1512] Get rid of dagParams in consensusStateManager
31 lines
772 B
Go
31 lines
772 B
Go
package utxoserialization
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
|
)
|
|
|
|
// ReadOnlyUTXOSetToProtoUTXOSet converts ReadOnlyUTXOSetIterator to ProtoUTXOSet
|
|
func ReadOnlyUTXOSetToProtoUTXOSet(iter model.ReadOnlyUTXOSetIterator) (*ProtoUTXOSet, error) {
|
|
protoUTXOSet := &ProtoUTXOSet{
|
|
Utxos: []*ProtoUTXO{},
|
|
}
|
|
|
|
for iter.Next() {
|
|
outpoint, entry, err := iter.Get()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serializedUTXOBytes, err := consensusserialization.SerializeUTXO(entry, outpoint)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
protoUTXOSet.Utxos = append(protoUTXOSet.Utxos, &ProtoUTXO{
|
|
EntryOutpointPair: serializedUTXOBytes,
|
|
})
|
|
}
|
|
return protoUTXOSet, nil
|
|
}
|