Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c78f869

Browse files
authored
Merge pull request #429 from iotaledger/fix/storage-deposit
Fix MinStorageDeposit for return output calculation
2 parents d533cb3 + 6b84149 commit c78f869

26 files changed

+49
-46
lines changed

address_alias.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (aliasAddr *AliasAddress) Clone() Address {
4747
return cpy
4848
}
4949

50-
func (aliasAddr *AliasAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
50+
func (aliasAddr *AliasAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
5151
return rentStruct.VBFactorData.Multiply(AliasAddressSerializedBytesSize)
5252
}
5353

address_ed25519.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (edAddr *Ed25519Address) Clone() Address {
4848
return cpy
4949
}
5050

51-
func (edAddr *Ed25519Address) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
51+
func (edAddr *Ed25519Address) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
5252
return rentStruct.VBFactorData.Multiply(Ed25519AddressSerializedBytesSize)
5353
}
5454

address_nft.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (nftAddr *NFTAddress) Clone() Address {
4747
return cpy
4848
}
4949

50-
func (nftAddr *NFTAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
50+
func (nftAddr *NFTAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
5151
return rentStruct.VBFactorData.Multiply(NFTAddressSerializedBytesSize)
5252
}
5353

feat.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func (f Features) Clone() Features {
5454
return cpy
5555
}
5656

57-
func (f Features) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
58-
var sumCost uint64
57+
func (f Features) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
58+
var sumCost VBytes
5959
for _, feat := range f {
6060
sumCost += feat.VBytes(rentStruct, nil)
6161
}

feat_issuer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (s *IssuerFeature) Clone() Feature {
2828
return &IssuerFeature{Address: s.Address.Clone()}
2929
}
3030

31-
func (s *IssuerFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
31+
func (s *IssuerFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
3232
return rentStruct.VBFactorData.Multiply(serializer.SmallTypeDenotationByteSize) +
3333
s.Address.VBytes(rentStruct, nil)
3434
}

feat_metadata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func (s *MetadataFeature) Clone() Feature {
2626
return &MetadataFeature{Data: append([]byte(nil), s.Data...)}
2727
}
2828

29-
func (s *MetadataFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
30-
return rentStruct.VBFactorData.Multiply(uint64(serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize + len(s.Data)))
29+
func (s *MetadataFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
30+
return rentStruct.VBFactorData.Multiply(VBytes(serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize + len(s.Data)))
3131
}
3232

3333
func (s *MetadataFeature) Equal(other Feature) bool {

feat_sender.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (s *SenderFeature) Clone() Feature {
2626
return &SenderFeature{Address: s.Address.Clone()}
2727
}
2828

29-
func (s *SenderFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) uint64 {
29+
func (s *SenderFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) VBytes {
3030
if f != nil {
3131
return f(rentStruct)
3232
}

feat_tag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func (s *TagFeature) Clone() Feature {
2525
return &TagFeature{Tag: append([]byte(nil), s.Tag...)}
2626
}
2727

28-
func (s *TagFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) uint64 {
28+
func (s *TagFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) VBytes {
2929
if f != nil {
3030
return f(rentStruct)
3131
}
32-
return rentStruct.VBFactorData.Multiply(serializer.SmallTypeDenotationByteSize + serializer.OneByte + uint64(len(s.Tag)))
32+
return rentStruct.VBFactorData.Multiply(VBytes(serializer.SmallTypeDenotationByteSize + serializer.OneByte + len(s.Tag)))
3333
}
3434

3535
func (s *TagFeature) Equal(other Feature) bool {

native_token.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ func (n NativeTokens) Clone() NativeTokens {
113113
return cpy
114114
}
115115

116-
func (n NativeTokens) VBytes(rentStruct *RentStructure, _ VBytesFunc) uint64 {
116+
func (n NativeTokens) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes {
117117
// length prefix + (native token count * static native token cost)
118-
return rentStruct.VBFactorData.Multiply(uint64(serializer.OneByte + len(n)*NativeTokenVByteCost))
118+
return rentStruct.VBFactorData.Multiply(VBytes(serializer.OneByte + len(n)*NativeTokenVByteCost))
119119
}
120120

121121
func (n NativeTokens) ToSerializables() serializer.Serializables {
@@ -168,7 +168,7 @@ func (n *NativeToken) Clone() *NativeToken {
168168
return cpy
169169
}
170170

171-
func (n *NativeToken) VBytes(_ *RentStructure, _ VBytesFunc) uint64 {
171+
func (n *NativeToken) VBytes(_ *RentStructure, _ VBytesFunc) VBytes {
172172
return NativeTokenVByteCost
173173
}
174174

output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
)
3030

3131
// defines the default offset virtual byte costs for an output.
32-
func outputOffsetVByteCost(rentStruct *RentStructure) uint64 {
32+
func outputOffsetVByteCost(rentStruct *RentStructure) VBytes {
3333
return rentStruct.VBFactorKey.Multiply(OutputIDLength) +
3434
// included block id, conf ms index, conf ms ts
3535
rentStruct.VBFactorData.Multiply(BlockIDLength+serializer.UInt32ByteSize+serializer.UInt32ByteSize)

0 commit comments

Comments
 (0)