Skip to content
Snippets Groups Projects
Commit 3997501e authored by Hans Moog's avatar Hans Moog
Browse files

Feat: started rewriting output model

parent feb06868
No related branches found
No related tags found
No related merge requests found
......@@ -104,6 +104,15 @@ func (output *Output) Balances() []*balance.Balance {
return output.balances
}
// ObjectStorageKey returns the key that is used to store the object in the database.
// It is required to match StorableObject interface.
func (output *Output) ObjectStorageKey() []byte {
return marshalutil.New(OutputIdLength).
WriteBytes(output.address.Bytes()).
WriteBytes(output.transactionId.Bytes()).
Bytes()
}
// ObjectStorageValue marshals the balances into a sequence of bytes - the address and transaction id are stored inside the key
// and are ignored here.
func (output *Output) ObjectStorageValue() (data []byte) {
......@@ -112,13 +121,11 @@ func (output *Output) ObjectStorageValue() (data []byte) {
// initialize helper
marshalUtil := marshalutil.New(4 + balanceCount*balance.Length)
// marshal the amount of balances
marshalUtil.WriteBool(output.solid)
marshalUtil.WriteTime(output.solidSince)
marshalUtil.WriteUint32(uint32(balanceCount))
// marshal balances
for _, balance := range output.balances {
marshalUtil.WriteBytes(balance.Bytes())
for _, balanceToMarshal := range output.balances {
marshalUtil.WriteBytes(balanceToMarshal.Bytes())
}
return
......@@ -137,11 +144,5 @@ func (output *Output) Update(other objectstorage.StorableObject) {
panic("this object should never be updated")
}
// ObjectStorageKey returns the key that is used to store the object in the database.
// It is required to match StorableObject interface.
func (output *Output) ObjectStorageKey() []byte {
return output.storageKey
}
// define contract (ensure that the struct fulfills the given interface)
var _ objectstorage.StorableObject = &Output{}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment