Documentation ¶
Index ¶
- Constants
- Variables
- func AccountSpammingFunction(ctx context.Context, s *Spammer) error
- func BigWalletsNeeded(rate int, duration time.Duration, spammingBatchSize int, splitFactor int) int
- func BlowballSpammingFunction(ctx context.Context, s *Spammer) error
- func CustomConflictSpammingFunc(ctx context.Context, s *Spammer) error
- func DataSpammingFunction(ctx context.Context, s *Spammer) error
- func EvaluateNumOfBatchInputs(params *ParametersSpammer) int
- func MinFaucetFundsDeposit(rate int, duration time.Duration, spammingBatchSize int) int
- func WithAccountAlias(alias string) options.Option[Spammer]
- func WithBlowballSize(size int) options.Option[Spammer]
- func WithEvilScenario(scenario *evilwallet.EvilScenario) options.Option[Spammer]
- func WithEvilWallet(initWallets *evilwallet.EvilWallet) options.Option[Spammer]
- func WithRate(rate int) options.Option[Spammer]
- func WithRateSetter(enable bool) options.Option[Spammer]
- func WithSpamDuration(maxDuration time.Duration) options.Option[Spammer]
- func WithSpammingFunc(spammerFunc SpammingFunc) options.Option[Spammer]
- type ErrorCounter
- type ParametersSpammer
- type Spammer
- func (s *Spammer) BatchesPrepared() uint64
- func (s *Spammer) BlocksSent() uint64
- func (s *Spammer) CheckIfAllSent()
- func (s *Spammer) PrepareAndPostBlock(ctx context.Context, issuanceData *models.PayloadIssuanceData, ...) iotago.BlockID
- func (s *Spammer) PrepareBlock(ctx context.Context, issuanceData *models.PayloadIssuanceData, ...) *iotago.Block
- func (s *Spammer) Spam(ctx context.Context)
- func (s *Spammer) StopSpamming()
- type SpammingFunc
- type State
Constants ¶
const ( TypeBlock = "blk" TypeTx = "tx" TypeDs = "ds" TypeAccounts = "accounts" TypeBlowball = "bb" )
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 ¶
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 BigWalletsNeeded ¶
BigWalletsNeeded calculates how many big wallets needs to be prepared for a spam based on provided spam details.
func EvaluateNumOfBatchInputs ¶
func EvaluateNumOfBatchInputs(params *ParametersSpammer) int
func MinFaucetFundsDeposit ¶
func WithAccountAlias ¶
WithAccountAlias sets the alias of the account that will be used to pay with mana for sent blocks.
func WithBlowballSize ¶
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 ¶
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 ¶
WithRateSetter enables setting rate of spammer.
func WithSpamDuration ¶
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 ¶
NewSpammer is a constructor of Spammer.
func (*Spammer) BatchesPrepared ¶
func (*Spammer) BlocksSent ¶
func (*Spammer) CheckIfAllSent ¶
func (s *Spammer) CheckIfAllSent()
func (*Spammer) PrepareAndPostBlock ¶
func (*Spammer) PrepareBlock ¶
func (*Spammer) Spam ¶
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.