Skip to content

Commit

Permalink
Do not spam too many gorutines for short spams
Browse files Browse the repository at this point in the history
  • Loading branch information
daria305 committed Apr 17, 2024
1 parent 1823bcb commit e541c25
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions programs/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (

"github.com/iotaledger/evil-tools/pkg/evilwallet"
"github.com/iotaledger/evil-tools/pkg/spammer"
"github.com/iotaledger/hive.go/lo"
"github.com/iotaledger/hive.go/log"
"github.com/iotaledger/hive.go/runtime/workerpool"
)

const (
MaxPendingRequestsRunning = 20
FaucetFundsAwaitTimeout = 3 * time.Minute
SelectCheckInterval = 2 * time.Second
SelectCheckInterval = 1 * time.Second
)

func faucetFundsNeededForSpamType(spamType string) bool {
Expand Down Expand Up @@ -44,7 +45,8 @@ func RequestFaucetFunds(ctx context.Context, logger log.Logger, paramsSpammer *s
}

canSubmit := func() bool {
return running.Load() < MaxPendingRequestsRunning && w.UnspentOutputsLeft(evilwallet.Fresh) <= 2*minFundsDeposit
maxRequests := int32(lo.Min(totalWalletsNeeded, MaxPendingRequestsRunning))
return running.Load() < maxRequests && w.UnspentOutputsLeft(evilwallet.Fresh) <= 2*minFundsDeposit
}

if paramsSpammer.Duration == spammer.InfiniteDuration {
Expand Down

0 comments on commit e541c25

Please sign in to comment.