From 3997501ef740f55ce08f43a67dfaebb4acb6d5f2 Mon Sep 17 00:00:00 2001
From: Hans Moog <hm@mkjc.net>
Date: Thu, 26 Mar 2020 14:04:24 +0100
Subject: [PATCH] Feat: started rewriting output model

---
 .../valuetransfer/transaction/output.go       | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/packages/binary/valuetransfer/transaction/output.go b/packages/binary/valuetransfer/transaction/output.go
index afc9cf40..50d0426e 100644
--- a/packages/binary/valuetransfer/transaction/output.go
+++ b/packages/binary/valuetransfer/transaction/output.go
@@ -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{}
-- 
GitLab