Documentation ¶
Index ¶
- Variables
- func BigWalletsNeeded(rate int, timeUnit, duration time.Duration) int
- func CustomConflictSpammingFunc(s *Spammer)
- func DataSpammingFunction(s *Spammer)
- type ErrorCounter
- type Logger
- type Options
- func WithBatchesSent(maxBatchesSent int) Options
- func WithErrorCounter(errCounter *ErrorCounter) Options
- func WithEvilScenario(scenario *evilwallet.EvilScenario) Options
- func WithEvilWallet(initWallets *evilwallet.EvilWallet) Options
- func WithLogTickerInterval(interval time.Duration) Options
- func WithNumberOfSpends(n int) Options
- func WithRateSetter(enable bool) Options
- func WithSpamDuration(maxDuration time.Duration) Options
- func WithSpamRate(rate int, timeUnit time.Duration) Options
- func WithSpammingFunc(spammerFunc func(s *Spammer)) Options
- func WithTimeDelayForDoubleSpend(timeDelay time.Duration) Options
- type SpamDetails
- type Spammer
- type SpammerFunc
- type State
Constants ¶
This section is empty.
Variables ¶
var ( ErrFailPostTransaction = errors.New("failed to post transaction") ErrFailSendDataBlock = errors.New("failed to send a data block") ErrTransactionIsNil = errors.New("provided transaction is nil") ErrFailToPrepareBatch = errors.New("custom conflict batch could not be prepared") ErrInsufficientClients = errors.New("insufficient clients to send conflicts") ErrInputsNotSolid = errors.New("not all inputs are solid") )
var DefaultSpamDetails = &SpamDetails{ Rate: 10, TimeUnit: time.Second, MaxDuration: time.Minute, MaxBatchesSent: 601, }
Functions ¶
func BigWalletsNeeded ¶
BigWalletsNeeded calculates how many big wallets needs to be prepared for a spam based on provided spam details.
func CustomConflictSpammingFunc ¶
func CustomConflictSpammingFunc(s *Spammer)
func DataSpammingFunction ¶
func DataSpammingFunction(s *Spammer)
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 Logger ¶
type Logger interface { Infof(template string, args ...interface{}) Info(args ...interface{}) Debugf(template string, args ...interface{}) Debug(args ...interface{}) Warn(args ...interface{}) Warnf(template string, args ...interface{}) Error(args ...interface{}) Errorf(template string, args ...interface{}) }
type Options ¶
type Options func(*Spammer)
func WithBatchesSent ¶
WithBatchesSent provides spammer with options regarding rate, time unit, and finishing spam criteria. Provide 0 to one of max parameters to skip it.
func WithErrorCounter ¶
func WithErrorCounter(errCounter *ErrorCounter) Options
WithErrorCounter allows for setting an error counter object, if not provided a new instance will be created.
func WithEvilScenario ¶
func WithEvilScenario(scenario *evilwallet.EvilScenario) Options
WithEvilScenario provides initWallet of spammer, if omitted spammer will prepare funds based on maxBlkSent parameter
func WithEvilWallet ¶
func WithEvilWallet(initWallets *evilwallet.EvilWallet) Options
WithEvilWallet provides evil wallet instance, that will handle all spam logic according to provided EvilScenario
func WithLogTickerInterval ¶
WithLogTickerInterval allows for changing interval between progress spamming logs, default is 30s.
func WithNumberOfSpends ¶
WithNumberOfSpends sets how many transactions should be created with the same input, e.g 3 for triple spend, 2 for double spend. For this to work user needs to make sure that there is enough number of clients.
func WithRateSetter ¶ added in v0.9.1
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 WithSpamRate ¶
WithSpamRate provides spammer with options regarding rate, time unit, and finishing spam criteria. Provide 0 to one of max parameters to skip it.
func WithSpammingFunc ¶
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.
type SpamDetails ¶
type Spammer ¶
type Spammer struct { SpamDetails *SpamDetails State *State UseRateSetter bool Clients evilwallet.Connector EvilWallet *evilwallet.EvilWallet EvilScenario *evilwallet.EvilScenario ErrCounter *ErrorCounter TimeDelayBetweenConflicts time.Duration NumberOfSpends 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 ¶ added in v0.9.2
func (*Spammer) CheckIfAllSent ¶
func (s *Spammer) CheckIfAllSent()
func (*Spammer) PostTransaction ¶
func (s *Spammer) PostTransaction(tx *devnetvm.Transaction, clt evilwallet.Client)
PostTransaction use provided client to issue a transaction. It chooses API method based on Spammer options. Counts errors, counts transactions and provides debug logs.
func (*Spammer) Spam ¶
func (s *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
type SpammerFunc ¶
type SpammerFunc func(*Spammer)