From 449d7c0cc48094f2327e73e1b2e898c0849ce3e2 Mon Sep 17 00:00:00 2001 From: LiYuqing Date: Tue, 7 May 2024 19:19:07 +1000 Subject: [PATCH] add object limit amount --- object.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/object.go b/object.go index 5481b35..e18e491 100644 --- a/object.go +++ b/object.go @@ -7,12 +7,18 @@ import ( "github.com/MixinNetwork/mixin/common" ) -func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, u *SafeUser) (*SequencerTransactionRequest, error) { +func CreateObjectStorageTransaction(ctx context.Context, extra []byte, traceId string, references []string, limit string, u *SafeUser) (*SequencerTransactionRequest, error) { if len(extra) > common.ExtraSizeStorageCapacity { return nil, fmt.Errorf("too large extra %d > %d", len(extra), common.ExtraSizeStorageCapacity) } step := common.NewIntegerFromString(common.ExtraStoragePriceStep) amount := step.Mul(len(extra)/common.ExtraSizeStorageStep + 1) + if limit != "" { + strl := common.NewIntegerFromString(limit) + if strl.Cmp(amount) > 0 { + amount = strl + } + } addr := common.NewAddressFromSeed(make([]byte, 64)) mix := NewMainnetMixAddress([]string{addr.String()}, 1) mix.Threshold = 64