Skip to content
Snippets Groups Projects
Unverified Commit de4a93f1 authored by Wolfgang Welz's avatar Wolfgang Welz Committed by GitHub
Browse files

Fix: Always use getter in ObjectStorageValue() (#542)

parent 0c1e54aa
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,7 @@ func (conflict *Conflict) MemberCount() int { ...@@ -92,7 +92,7 @@ func (conflict *Conflict) MemberCount() int {
} }
// IncreaseMemberCount offers a thread safe way to increase the MemberCount property. // IncreaseMemberCount offers a thread safe way to increase the MemberCount property.
func (conflict *Conflict) IncreaseMemberCount(optionalDelta ...int) (newMemberCount int) { func (conflict *Conflict) IncreaseMemberCount(optionalDelta ...int) int {
delta := uint32(1) delta := uint32(1)
if len(optionalDelta) >= 1 { if len(optionalDelta) >= 1 {
delta = uint32(optionalDelta[0]) delta = uint32(optionalDelta[0])
...@@ -103,9 +103,8 @@ func (conflict *Conflict) IncreaseMemberCount(optionalDelta ...int) (newMemberCo ...@@ -103,9 +103,8 @@ func (conflict *Conflict) IncreaseMemberCount(optionalDelta ...int) (newMemberCo
conflict.memberCount = conflict.memberCount + delta conflict.memberCount = conflict.memberCount + delta
conflict.SetModified() conflict.SetModified()
newMemberCount = int(conflict.memberCount)
return return int(conflict.memberCount)
} }
// DecreaseMemberCount offers a thread safe way to decrease the MemberCount property. // DecreaseMemberCount offers a thread safe way to decrease the MemberCount property.
...@@ -150,7 +149,7 @@ func (conflict *Conflict) ObjectStorageKey() []byte { ...@@ -150,7 +149,7 @@ func (conflict *Conflict) ObjectStorageKey() []byte {
// Branch. // Branch.
func (conflict *Conflict) ObjectStorageValue() []byte { func (conflict *Conflict) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.UINT32_SIZE). return marshalutil.New(marshalutil.UINT32_SIZE).
WriteUint32(conflict.memberCount). WriteUint32(uint32(conflict.MemberCount())).
Bytes() Bytes()
} }
......
...@@ -108,7 +108,7 @@ func (missingOutput *MissingOutput) ObjectStorageKey() []byte { ...@@ -108,7 +108,7 @@ func (missingOutput *MissingOutput) ObjectStorageKey() []byte {
// interface. // interface.
func (missingOutput *MissingOutput) ObjectStorageValue() []byte { func (missingOutput *MissingOutput) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.TIME_SIZE). return marshalutil.New(marshalutil.TIME_SIZE).
WriteTime(missingOutput.missingSince). WriteTime(missingOutput.MissingSince()).
Bytes() Bytes()
} }
......
...@@ -112,7 +112,7 @@ func (missingPayload *MissingPayload) ObjectStorageKey() []byte { ...@@ -112,7 +112,7 @@ func (missingPayload *MissingPayload) ObjectStorageKey() []byte {
// ObjectStorageValue is required to match the encoding.BinaryMarshaler interface. // ObjectStorageValue is required to match the encoding.BinaryMarshaler interface.
func (missingPayload *MissingPayload) ObjectStorageValue() (data []byte) { func (missingPayload *MissingPayload) ObjectStorageValue() (data []byte) {
return marshalutil.New(marshalutil.TIME_SIZE). return marshalutil.New(marshalutil.TIME_SIZE).
WriteTime(missingPayload.missingSince). WriteTime(missingPayload.MissingSince()).
Bytes() Bytes()
} }
......
...@@ -426,22 +426,23 @@ func (output *Output) ObjectStorageKey() []byte { ...@@ -426,22 +426,23 @@ func (output *Output) ObjectStorageKey() []byte {
// and are ignored here. // and are ignored here.
func (output *Output) ObjectStorageValue() []byte { func (output *Output) ObjectStorageValue() []byte {
// determine amount of balances in the output // determine amount of balances in the output
balanceCount := len(output.balances) balances := output.Balances()
balanceCount := len(balances)
// initialize helper // initialize helper
marshalUtil := marshalutil.New(branchmanager.BranchIDLength + 6*marshalutil.BOOL_SIZE + marshalutil.TIME_SIZE + transaction.IDLength + marshalutil.UINT32_SIZE + marshalutil.UINT32_SIZE + balanceCount*balance.Length) marshalUtil := marshalutil.New(branchmanager.BranchIDLength + 6*marshalutil.BOOL_SIZE + marshalutil.TIME_SIZE + transaction.IDLength + marshalutil.UINT32_SIZE + marshalutil.UINT32_SIZE + balanceCount*balance.Length)
marshalUtil.WriteBytes(output.branchID.Bytes()) marshalUtil.WriteBytes(output.branchID.Bytes())
marshalUtil.WriteBool(output.solid) marshalUtil.WriteBool(output.Solid())
marshalUtil.WriteTime(output.solidificationTime) marshalUtil.WriteTime(output.SolidificationTime())
marshalUtil.WriteBytes(output.firstConsumer.Bytes()) marshalUtil.WriteBytes(output.firstConsumer.Bytes())
marshalUtil.WriteUint32(uint32(output.consumerCount)) marshalUtil.WriteUint32(uint32(output.ConsumerCount()))
marshalUtil.WriteBool(output.Preferred()) marshalUtil.WriteBool(output.Preferred())
marshalUtil.WriteBool(output.Finalized()) marshalUtil.WriteBool(output.Finalized())
marshalUtil.WriteBool(output.Liked()) marshalUtil.WriteBool(output.Liked())
marshalUtil.WriteBool(output.Confirmed()) marshalUtil.WriteBool(output.Confirmed())
marshalUtil.WriteBool(output.Rejected()) marshalUtil.WriteBool(output.Rejected())
marshalUtil.WriteUint32(uint32(balanceCount)) marshalUtil.WriteUint32(uint32(balanceCount))
for _, balanceToMarshal := range output.balances { for _, balanceToMarshal := range balances {
marshalUtil.WriteBytes(balanceToMarshal.Bytes()) marshalUtil.WriteBytes(balanceToMarshal.Bytes())
} }
......
...@@ -305,12 +305,12 @@ func (payloadMetadata *PayloadMetadata) Update(other objectstorage.StorableObjec ...@@ -305,12 +305,12 @@ func (payloadMetadata *PayloadMetadata) Update(other objectstorage.StorableObjec
// ObjectStorageValue is required to match the encoding.BinaryMarshaler interface. // ObjectStorageValue is required to match the encoding.BinaryMarshaler interface.
func (payloadMetadata *PayloadMetadata) ObjectStorageValue() []byte { func (payloadMetadata *PayloadMetadata) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.TIME_SIZE + 4*marshalutil.BOOL_SIZE). return marshalutil.New(marshalutil.TIME_SIZE + 4*marshalutil.BOOL_SIZE).
WriteTime(payloadMetadata.solidificationTime). WriteTime(payloadMetadata.SoldificationTime()).
WriteBool(payloadMetadata.solid). WriteBool(payloadMetadata.IsSolid()).
WriteBool(payloadMetadata.liked). WriteBool(payloadMetadata.Liked()).
WriteBool(payloadMetadata.confirmed). WriteBool(payloadMetadata.Confirmed()).
WriteBool(payloadMetadata.rejected). WriteBool(payloadMetadata.Rejected()).
WriteBytes(payloadMetadata.branchID.Bytes()). WriteBytes(payloadMetadata.BranchID().Bytes()).
Bytes() Bytes()
} }
......
...@@ -119,8 +119,8 @@ func (messageMetadata *MessageMetadata) ObjectStorageKey() []byte { ...@@ -119,8 +119,8 @@ func (messageMetadata *MessageMetadata) ObjectStorageKey() []byte {
func (messageMetadata *MessageMetadata) ObjectStorageValue() []byte { func (messageMetadata *MessageMetadata) ObjectStorageValue() []byte {
return marshalutil.New(). return marshalutil.New().
WriteTime(messageMetadata.receivedTime). WriteTime(messageMetadata.receivedTime).
WriteTime(messageMetadata.solidificationTime). WriteTime(messageMetadata.SoldificationTime()).
WriteBool(messageMetadata.solid). WriteBool(messageMetadata.IsSolid()).
Bytes() Bytes()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment