Skip to content

Commit 2b12eb2

Browse files
authored
add object limit amount (#173)
1 parent bc96c4e commit 2b12eb2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

object.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import (
77
"github.com/MixinNetwork/mixin/common"
88
)
99

10-
func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, u *SafeUser) (*SequencerTransactionRequest, error) {
10+
func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, limit string, u *SafeUser) (*SequencerTransactionRequest, error) {
1111
if len(extra) > common.ExtraSizeStorageCapacity {
1212
return nil, fmt.Errorf("too large extra %d > %d", len(extra), common.ExtraSizeStorageCapacity)
1313
}
1414
step := common.NewIntegerFromString(common.ExtraStoragePriceStep)
1515
amount := step.Mul(len(extra)/common.ExtraSizeStorageStep + 1)
16+
if limit != "" {
17+
strl := common.NewIntegerFromString(limit)
18+
if strl.Cmp(amount) > 0 {
19+
amount = strl
20+
}
21+
}
1622
addr := common.NewAddressFromSeed(make([]byte, 64))
1723
mix := NewMainnetMixAddress([]string{addr.String()}, 1)
1824
mix.Threshold = 64

0 commit comments

Comments
 (0)