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 {
}
// 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)
if len(optionalDelta) >= 1 {
delta = uint32(optionalDelta[0])
......@@ -103,9 +103,8 @@ func (conflict *Conflict) IncreaseMemberCount(optionalDelta ...int) (newMemberCo
conflict.memberCount = conflict.memberCount + delta
conflict.SetModified()
newMemberCount = int(conflict.memberCount)
return
return int(conflict.memberCount)
}
// DecreaseMemberCount offers a thread safe way to decrease the MemberCount property.
......@@ -150,7 +149,7 @@ func (conflict *Conflict) ObjectStorageKey() []byte {
// Branch.
func (conflict *Conflict) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.UINT32_SIZE).
WriteUint32(conflict.memberCount).
WriteUint32(uint32(conflict.MemberCount())).
Bytes()
}
......
......@@ -108,7 +108,7 @@ func (missingOutput *MissingOutput) ObjectStorageKey() []byte {
// interface.
func (missingOutput *MissingOutput) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.TIME_SIZE).
WriteTime(missingOutput.missingSince).
WriteTime(missingOutput.MissingSince()).
Bytes()
}
......
......@@ -112,7 +112,7 @@ func (missingPayload *MissingPayload) ObjectStorageKey() []byte {
// ObjectStorageValue is required to match the encoding.BinaryMarshaler interface.
func (missingPayload *MissingPayload) ObjectStorageValue() (data []byte) {
return marshalutil.New(marshalutil.TIME_SIZE).
WriteTime(missingPayload.missingSince).
WriteTime(missingPayload.MissingSince()).
Bytes()
}
......
......@@ -426,22 +426,23 @@ func (output *Output) ObjectStorageKey() []byte {
// and are ignored here.
func (output *Output) ObjectStorageValue() []byte {
// determine amount of balances in the output
balanceCount := len(output.balances)
balances := output.Balances()
balanceCount := len(balances)
// 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.WriteBytes(output.branchID.Bytes())
marshalUtil.WriteBool(output.solid)
marshalUtil.WriteTime(output.solidificationTime)
marshalUtil.WriteBool(output.Solid())
marshalUtil.WriteTime(output.SolidificationTime())
marshalUtil.WriteBytes(output.firstConsumer.Bytes())
marshalUtil.WriteUint32(uint32(output.consumerCount))
marshalUtil.WriteUint32(uint32(output.ConsumerCount()))
marshalUtil.WriteBool(output.Preferred())
marshalUtil.WriteBool(output.Finalized())
marshalUtil.WriteBool(output.Liked())
marshalUtil.WriteBool(output.Confirmed())
marshalUtil.WriteBool(output.Rejected())
marshalUtil.WriteUint32(uint32(balanceCount))
for _, balanceToMarshal := range output.balances {
for _, balanceToMarshal := range balances {
marshalUtil.WriteBytes(balanceToMarshal.Bytes())
}
......
......@@ -305,12 +305,12 @@ func (payloadMetadata *PayloadMetadata) Update(other objectstorage.StorableObjec
// ObjectStorageValue is required to match the encoding.BinaryMarshaler interface.
func (payloadMetadata *PayloadMetadata) ObjectStorageValue() []byte {
return marshalutil.New(marshalutil.TIME_SIZE + 4*marshalutil.BOOL_SIZE).
WriteTime(payloadMetadata.solidificationTime).
WriteBool(payloadMetadata.solid).
WriteBool(payloadMetadata.liked).
WriteBool(payloadMetadata.confirmed).
WriteBool(payloadMetadata.rejected).
WriteBytes(payloadMetadata.branchID.Bytes()).
WriteTime(payloadMetadata.SoldificationTime()).
WriteBool(payloadMetadata.IsSolid()).
WriteBool(payloadMetadata.Liked()).
WriteBool(payloadMetadata.Confirmed()).
WriteBool(payloadMetadata.Rejected()).
WriteBytes(payloadMetadata.BranchID().Bytes()).
Bytes()
}
......
......@@ -119,8 +119,8 @@ func (messageMetadata *MessageMetadata) ObjectStorageKey() []byte {
func (messageMetadata *MessageMetadata) ObjectStorageValue() []byte {
return marshalutil.New().
WriteTime(messageMetadata.receivedTime).
WriteTime(messageMetadata.solidificationTime).
WriteBool(messageMetadata.solid).
WriteTime(messageMetadata.SoldificationTime()).
WriteBool(messageMetadata.IsSolid()).
Bytes()
}
......
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