spammer

package
v0.1.0-alpha.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeBlock    = "blk"
	TypeTx       = "tx"
	TypeDs       = "ds"
	TypeAccounts = "accounts"
	TypeBlowball = "bb"
)
View Source
const (
	// MinSpamDurationFundsReady is the minimum duration for which the funds need to be ready before the spammer starts spamming.
	MinSpamDurationFundsReady = 3 * time.Minute
	InfiniteDuration          = time.Duration(-1)
)

Variables

View Source
var (
	ErrFailPostBlock       = ierrors.New("failed to post block")
	ErrPayloadIsNil        = ierrors.New("provided payload is nil")
	ErrFailToPrepareBatch  = ierrors.New("custom conflict batch could not be prepared")
	ErrInsufficientClients = ierrors.New("insufficient clients to send conflicts")
	ErrFailGetAccount      = ierrors.New("failed to get account from the account wallet")
	ErrUnknownPayloadType  = ierrors.New("unknown payload type")
)

Functions

func AccountSpammingFunction

func AccountSpammingFunction(ctx context.Context, s *Spammer) error

func BigWalletsNeeded

func BigWalletsNeeded(rate int, duration time.Duration, spammingBatchSize int, splitFactor int) int

BigWalletsNeeded calculates how many big wallets needs to be prepared for a spam based on provided spam details.

func BlowballSpammingFunction

func BlowballSpammingFunction(ctx context.Context, s *Spammer) error

func CustomConflictSpammingFunc

func CustomConflictSpammingFunc(ctx context.Context, s *Spammer) error

func DataSpammingFunction

func DataSpammingFunction(ctx context.Context, s *Spammer) error

func EvaluateNumOfBatchInputs

func EvaluateNumOfBatchInputs(params *ParametersSpammer) int

func MinFaucetFundsDeposit

func MinFaucetFundsDeposit(rate int, duration time.Duration, spammingBatchSize int) int

func WithAccountAlias

func WithAccountAlias(alias string) options.Option[Spammer]

WithAccountAlias sets the alias of the account that will be used to pay with mana for sent blocks.

func WithBlowballSize

func WithBlowballSize(size int) options.Option[Spammer]

WithBlowballSize provides spammer with options regarding blowball size.

func WithEvilScenario

func WithEvilScenario(scenario *evilwallet.EvilScenario) options.Option[Spammer]

WithEvilScenario provides initWallet of spammer, if omitted spammer will prepare funds based on maxBlkSent parameter.

func WithEvilWallet

func WithEvilWallet(initWallets *evilwallet.EvilWallet) options.Option[Spammer]

WithEvilWallet provides evil wallet instance, that will handle all spam logic according to provided EvilScenario.

func WithRate

func WithRate(rate int) options.Option[Spammer]

WithRate provides spammer with options regarding rate, time unit, and finishing spam criteria. Provide 0 to one of max parameters to skip it.

func WithRateSetter

func WithRateSetter(enable bool) options.Option[Spammer]

WithRateSetter enables setting rate of spammer.

func WithSpamDuration

func WithSpamDuration(maxDuration time.Duration) options.Option[Spammer]

WithSpamDuration provides spammer with options regarding rate, time unit, and finishing spam criteria. Provide 0 to one of max parameters to skip it.

func WithSpammingFunc

func WithSpammingFunc(spammerFunc SpammingFunc) options.Option[Spammer]

WithSpammingFunc sets core function of the spammer with spamming logic, needs to use done spammer's channel to communicate. end of spamming and errors. Default one is the CustomConflictSpammingFunc.

Types

type ErrorCounter

type ErrorCounter struct {
	// contains filtered or unexported fields
}

ErrorCounter counts errors that appeared during the spam, as during the spam they are ignored and allows to print the summary (might be useful for debugging).

func NewErrorCount

func NewErrorCount() *ErrorCounter

func (*ErrorCounter) CountError

func (e *ErrorCounter) CountError(err error)

func (*ErrorCounter) GetErrorsSummary

func (e *ErrorCounter) GetErrorsSummary() string

func (*ErrorCounter) GetTotalErrorCount

func (e *ErrorCounter) GetTotalErrorCount() int64

type ParametersSpammer

type ParametersSpammer struct {
	Type                  string        `` /* 295-byte string literal not displayed */
	Rate                  int           `` /* 166-byte string literal not displayed */
	Duration              time.Duration `` /* 273-byte string literal not displayed */
	Account               string        `default:"" usage:"Account alias to be used for the spam. Account should be created first with accounts tool."`
	RateSetterEnabled     bool          `default:"false" usage:"Enable the rate setter, which will set the rate for the spammer. To enable provide an empty flag."`
	DeepSpamEnabled       bool          `default:"false" usage:"Enable the deep spam, by reusing outputs created during the spam. To enable provide an empty flag."`
	ReuseEnabled          bool          `default:"false" usage:"Enable the reuse of outputs created during the spam. To enable provide an empty flag."`
	AutoRequestingEnabled bool          `` /* 139-byte string literal not displayed */
	AutoRequestingAmount  int64         `default:"1000" usage:"Amount of tokens to be requested from faucet for the spammer. To enable provide an empty flag."`
	NSpend                int           `` /* 152-byte string literal not displayed */
	BlowballSize          int           `default:"30" usage:"Size of the blowball to be used in blowball spammer. To enable provide an empty flag."`
}

type Spammer

type Spammer struct {
	log.Logger

	State      *State
	Clients    models.Connector
	ErrCounter *ErrorCounter

	MaxBatchesSent int
	NumberOfSpends int

	// options
	EvilWallet   *evilwallet.EvilWallet
	EvilScenario *evilwallet.EvilScenario

	IssuerAlias   string
	UseRateSetter bool
	Rate          int
	MaxDuration   time.Duration
	BlowballSize  int
	// contains filtered or unexported fields
}

Spammer is a utility object for new spammer creations, can be modified by passing options. Mandatory options: WithClients, WithSpammingFunc Not mandatory options, if not provided spammer will use default settings: WithSpamDetails, WithEvilWallet, WithErrorCounter, WithLogTickerInterval.

func NewSpammer

func NewSpammer(logger log.Logger, opts ...options.Option[Spammer]) *Spammer

NewSpammer is a constructor of Spammer.

func (*Spammer) BatchesPrepared

func (s *Spammer) BatchesPrepared() uint64

func (*Spammer) BlocksSent

func (s *Spammer) BlocksSent() uint64

func (*Spammer) CheckIfAllSent

func (s *Spammer) CheckIfAllSent()

func (*Spammer) PrepareAndPostBlock

func (s *Spammer) PrepareAndPostBlock(ctx context.Context, issuanceData *models.PayloadIssuanceData, clt models.Client, awaitAcceptance ...bool) iotago.BlockID

func (*Spammer) PrepareBlock

func (s *Spammer) PrepareBlock(ctx context.Context, issuanceData *models.PayloadIssuanceData, clt models.Client, strongParents ...iotago.BlockID) *iotago.Block

func (*Spammer) Spam

func (s *Spammer) Spam(ctx context.Context)

Spam runs the spammer. Function will stop after maxDuration time will pass or when maxBlkSent will be exceeded.

func (*Spammer) StopSpamming

func (s *Spammer) StopSpamming()

StopSpamming finishes tasks before shutting down the spammer.

type SpammingFunc

type SpammingFunc func(context.Context, *Spammer) error

type State

type State struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL