Documentation ¶
Index ¶
- Constants
- Variables
- func AliasIDFromFoundryID(foundryID iotago.FoundryID) (iotago.AliasID, error)
- type AddInputOption
- type AddInputOptions
- type AddOutputOption
- type AddOutputOptions
- type AliasUTXO
- func (u *AliasUTXO) AppendFoundryOutput(foundryOutput *UTXO)
- func (u *AliasUTXO) FoundryOutputs() []*UTXO
- func (u *AliasUTXO) Output() iotago.Output
- func (u *AliasUTXO) OutputID() iotago.OutputID
- func (u *AliasUTXO) PendingBlockID() iotago.BlockID
- func (u *AliasUTXO) SetFoundryOutputs(foundryOutputs []*UTXO)
- type AvgSpamMetrics
- type BlockMetadataFunc
- type CPUUsageUpdater
- type Events
- type GetTipsPoolSizesFunc
- type IsNodeHealthyFunc
- type LedgerAccount
- func (la *LedgerAccount) Address() iotago.Address
- func (la *LedgerAccount) AddressBech32() string
- func (la *LedgerAccount) AliasOutputs() []*AliasUTXO
- func (la *LedgerAccount) AliasOutputsCount() int
- func (la *LedgerAccount) AppendAliasOutput(aliasOutput *AliasUTXO)
- func (la *LedgerAccount) AppendBasicOutput(basicOutput *UTXO)
- func (la *LedgerAccount) AppendFoundryOutput(foundryOutput *UTXO) error
- func (la *LedgerAccount) AppendNFTOutput(nftOutput *UTXO)
- func (la *LedgerAccount) BasicOutputs() []*UTXO
- func (la *LedgerAccount) BasicOutputsCount() int
- func (la *LedgerAccount) CleanupOwnershipBasicOutputs()
- func (la *LedgerAccount) ClearSpentOutputs(spentsMap map[iotago.OutputID]struct{})
- func (la *LedgerAccount) Empty() bool
- func (la *LedgerAccount) FoundryOutputsCount() int
- func (la *LedgerAccount) NFTOutputs() []*UTXO
- func (la *LedgerAccount) NFTOutputsCount() int
- func (la *LedgerAccount) QueryOutputsFromIndexer(ctx context.Context, indexer nodeclient.IndexerClient, allowNativeTokens bool, ...) error
- func (la *LedgerAccount) ResetAliasOutputs()
- func (la *LedgerAccount) ResetBasicOutputs()
- func (la *LedgerAccount) ResetFoundryOutputs()
- func (la *LedgerAccount) ResetNFTOutputs()
- func (la *LedgerAccount) ResetOutputs()
- func (la *LedgerAccount) SetAliasOutputs(aliasOutputs []*AliasUTXO)
- func (la *LedgerAccount) SetBasicOutputs(basicOutputs []*UTXO)
- func (la *LedgerAccount) SetNFTOutputs(nftOutputs []*UTXO)
- func (la *LedgerAccount) Signer() iotago.AddressSigner
- type Metadata
- type Metrics
- type OutputWithOwnership
- type ProtocolParametersFunc
- type RequestTipsFunc
- type SendBlockFunc
- type Server
- type SpamBuilder
- func (b *SpamBuilder) AddInput(input UTXOInterface, opts ...AddInputOption) bool
- func (b *SpamBuilder) AddOutput(output iotago.Output, opts ...AddOutputOption) bool
- func (b *SpamBuilder) AddOutputWithOwnership(output iotago.Output, ownedOutputs []*UTXO, opts ...AddOutputOption) bool
- func (b *SpamBuilder) Clone() *SpamBuilder
- func (b *SpamBuilder) ConsumedInputsEmpty() bool
- func (b *SpamBuilder) InputConsumed(outputID iotago.OutputID) bool
- type SpamStats
- type Spammer
- func (s *Spammer) ApplyNewLedgerUpdate(ctx context.Context, msIndex iotago.MilestoneIndex, ...) error
- func (s *Spammer) BPSRateLimitRunning() float64
- func (s *Spammer) BuildTaggedDataBlockAndSend(ctx context.Context) error
- func (s *Spammer) BuildTransactionPayloadBlockAndSend(ctx context.Context, spamBuilder *SpamBuilder) ([]UTXOInterface, *UTXO, error)
- func (s *Spammer) CPUMaxUsageRunning() float64
- func (s *Spammer) IsRunning() bool
- func (s *Spammer) IsValueSpamEnabled() bool
- func (s *Spammer) MeasureSpammerMetrics()
- func (s *Spammer) SpammerWorkersRunning() int
- func (s *Spammer) Start(valueSpamEnabled *bool, bpsRateLimit *float64, cpuMaxUsage *float64, ...) error
- func (s *Spammer) Stop() error
- type UTXO
- type UTXOInterface
Constants ¶
const ( // RouteSpammerStatus is the route to get the status of the spammer. // GET the current status of the spammer. RouteSpammerStatus = "/status" // RouteSpammerStart is the route to start the spammer (with optional changing the settings). // POST the settings to change and start the spammer. RouteSpammerStart = "/start" // RouteSpammerStop is the route to stop the spammer. // POST to stop the spammer. RouteSpammerStop = "/stop" )
const ( AddressIndexSender = 0 AddressIndexReceiver = 1 )
const ( IndexerQueryMaxResults = 1000 IndexerQueryTimeout = 15 * time.Second )
const (
APIRoute = "/api/spammer/v1"
)
Variables ¶
var ( // ErrCPUPercentageUnknown is returned if the CPU usage couldn't be determined. ErrCPUPercentageUnknown = errors.New("CPU percentage unknown") )
Functions ¶
Types ¶
type AddInputOption ¶ added in v1.0.0
type AddInputOption func(opts *AddInputOptions)
AddInputOption is a function setting an AddInput option.
func WithInputMaxInputsCount ¶ added in v1.0.0
func WithInputMaxInputsCount(maxInputsCount int) AddInputOption
WithInputMaxInputsCount sets the maximum allowed inputs.
func WithInputMaxTipsCount ¶ added in v1.0.0
func WithInputMaxTipsCount(maxTipsCount int) AddInputOption
WithInputMaxTipsCount sets the maximum allowed required tips.
type AddInputOptions ¶ added in v1.0.0
type AddInputOptions struct {
// contains filtered or unexported fields
}
AddInputOptions define options for the AddInput function.
type AddOutputOption ¶ added in v1.0.0
type AddOutputOption func(opts *AddOutputOptions)
AddOutputOption is a function setting an AddOutput option.
func WithOutputMaxOutputsCount ¶ added in v1.0.0
func WithOutputMaxOutputsCount(maxOutputsCount int) AddOutputOption
WithInputMaxInputsCount sets the maximum allowed outputs.
type AddOutputOptions ¶ added in v1.0.0
type AddOutputOptions struct {
// contains filtered or unexported fields
}
AddOutputOptions define options for the AddOutput function.
type AliasUTXO ¶ added in v1.0.0
type AliasUTXO struct {
// contains filtered or unexported fields
}
func NewAliasUTXO ¶ added in v1.0.0
func (*AliasUTXO) AppendFoundryOutput ¶ added in v1.0.0
func (*AliasUTXO) FoundryOutputs ¶ added in v1.0.0
func (*AliasUTXO) PendingBlockID ¶ added in v1.0.0
func (*AliasUTXO) SetFoundryOutputs ¶ added in v1.0.0
type AvgSpamMetrics ¶
type AvgSpamMetrics struct { NewBlocks uint32 `json:"newBlocks"` AverageBlocksPerSecond float32 `json:"avgBlocks"` }
AvgSpamMetrics are average metrics of the created spam.
type BlockMetadataFunc ¶ added in v1.0.0
BlockMetadataFunc is a function to fetch the required metadata for a given block ID. This should return nil if the block is not found.
type CPUUsageUpdater ¶
CPUUsageUpdater measures the CPU usage.
func NewCPUUsageUpdater ¶
func NewCPUUsageUpdater(sampleTime time.Duration, sleepTime time.Duration) *CPUUsageUpdater
NewCPUUsageUpdater creates a new CPUUsageUpdater to measure the CPU usage.
func (*CPUUsageUpdater) CPUUsage ¶
func (c *CPUUsageUpdater) CPUUsage() (float64, error)
CPUUsage returns latest cpu usage.
func (*CPUUsageUpdater) CPUUsageGuessWithAdditionalWorker ¶
func (c *CPUUsageUpdater) CPUUsageGuessWithAdditionalWorker() (float64, error)
CPUUsageGuessWithAdditionalWorker returns guessed cpu usage with another core running at 100% load.
func (*CPUUsageUpdater) Run ¶
func (c *CPUUsageUpdater) Run(ctx context.Context)
Run measures cpu usage until the context is canceled.
func (*CPUUsageUpdater) WaitForLowerCPUUsage ¶
func (c *CPUUsageUpdater) WaitForLowerCPUUsage(ctx context.Context, cpuMaxUsage float64) error
WaitForLowerCPUUsage waits until the cpu usage drops below cpuMaxUsage.
type Events ¶ added in v1.0.0
type Events struct { // Fired when a single spam block is issued. SpamPerformed *event.Event1[*SpamStats] // Fired when average spam metrics were updated by the worker. AvgSpamMetricsUpdated *event.Event1[*AvgSpamMetrics] }
Events are the events issued by the spammer.
type GetTipsPoolSizesFunc ¶
GetTipsPoolSizesFunc returns the current tip pool sizes of the node.
type IsNodeHealthyFunc ¶
type IsNodeHealthyFunc = func() bool
IsNodeHealthyFunc returns whether the node is synced, has active peers and its latest milestone is not too old.
type LedgerAccount ¶ added in v1.0.0
type LedgerAccount struct {
// contains filtered or unexported fields
}
func NewLedgerAccount ¶ added in v1.0.0
func NewLedgerAccount(wallet *hdwallet.HDWallet, addressIndex uint64, protocolParametersFunc func() *iotago.ProtocolParameters) (*LedgerAccount, error)
func (*LedgerAccount) Address ¶ added in v1.0.0
func (la *LedgerAccount) Address() iotago.Address
func (*LedgerAccount) AddressBech32 ¶ added in v1.0.0
func (la *LedgerAccount) AddressBech32() string
func (*LedgerAccount) AliasOutputs ¶ added in v1.0.0
func (la *LedgerAccount) AliasOutputs() []*AliasUTXO
func (*LedgerAccount) AliasOutputsCount ¶ added in v1.0.0
func (la *LedgerAccount) AliasOutputsCount() int
func (*LedgerAccount) AppendAliasOutput ¶ added in v1.0.0
func (la *LedgerAccount) AppendAliasOutput(aliasOutput *AliasUTXO)
func (*LedgerAccount) AppendBasicOutput ¶ added in v1.0.0
func (la *LedgerAccount) AppendBasicOutput(basicOutput *UTXO)
func (*LedgerAccount) AppendFoundryOutput ¶ added in v1.0.0
func (la *LedgerAccount) AppendFoundryOutput(foundryOutput *UTXO) error
func (*LedgerAccount) AppendNFTOutput ¶ added in v1.0.0
func (la *LedgerAccount) AppendNFTOutput(nftOutput *UTXO)
func (*LedgerAccount) BasicOutputs ¶ added in v1.0.0
func (la *LedgerAccount) BasicOutputs() []*UTXO
func (*LedgerAccount) BasicOutputsCount ¶ added in v1.0.0
func (la *LedgerAccount) BasicOutputsCount() int
func (*LedgerAccount) CleanupOwnershipBasicOutputs ¶ added in v1.0.0
func (la *LedgerAccount) CleanupOwnershipBasicOutputs()
func (*LedgerAccount) ClearSpentOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ClearSpentOutputs(spentsMap map[iotago.OutputID]struct{})
func (*LedgerAccount) Empty ¶ added in v1.0.0
func (la *LedgerAccount) Empty() bool
func (*LedgerAccount) FoundryOutputsCount ¶ added in v1.0.0
func (la *LedgerAccount) FoundryOutputsCount() int
func (*LedgerAccount) NFTOutputs ¶ added in v1.0.0
func (la *LedgerAccount) NFTOutputs() []*UTXO
func (*LedgerAccount) NFTOutputsCount ¶ added in v1.0.0
func (la *LedgerAccount) NFTOutputsCount() int
func (*LedgerAccount) QueryOutputsFromIndexer ¶ added in v1.0.0
func (la *LedgerAccount) QueryOutputsFromIndexer(ctx context.Context, indexer nodeclient.IndexerClient, allowNativeTokens bool, queryBasicOutputs bool, queryAliasOutputs bool, queryFoundryOutputs bool, queryNFTOutputs bool, maxResults ...int) error
func (*LedgerAccount) ResetAliasOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ResetAliasOutputs()
func (*LedgerAccount) ResetBasicOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ResetBasicOutputs()
func (*LedgerAccount) ResetFoundryOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ResetFoundryOutputs()
func (*LedgerAccount) ResetNFTOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ResetNFTOutputs()
func (*LedgerAccount) ResetOutputs ¶ added in v1.0.0
func (la *LedgerAccount) ResetOutputs()
func (*LedgerAccount) SetAliasOutputs ¶ added in v1.0.0
func (la *LedgerAccount) SetAliasOutputs(aliasOutputs []*AliasUTXO)
func (*LedgerAccount) SetBasicOutputs ¶ added in v1.0.0
func (la *LedgerAccount) SetBasicOutputs(basicOutputs []*UTXO)
func (*LedgerAccount) SetNFTOutputs ¶ added in v1.0.0
func (la *LedgerAccount) SetNFTOutputs(nftOutputs []*UTXO)
func (*LedgerAccount) Signer ¶ added in v1.0.0
func (la *LedgerAccount) Signer() iotago.AddressSigner
type OutputWithOwnership ¶ added in v1.0.0
type ProtocolParametersFunc ¶ added in v1.0.0
type ProtocolParametersFunc = func() *iotago.ProtocolParameters
ProtocolParametersFunc returns the latest protocol parameters from the node.
type RequestTipsFunc ¶
type RequestTipsFunc = func(ctx context.Context, count uint32, allowSemiLazy bool) (iotago.BlockIDs, error)
RequestTipsFunc returns tips chosen by the node.
type SendBlockFunc ¶
SendBlockFunc is a function which sends a block to the network.
type SpamBuilder ¶ added in v1.0.0
type SpamBuilder struct {
// contains filtered or unexported fields
}
func NewSpamBuilder ¶ added in v1.0.0
func NewSpamBuilder(accountSender *LedgerAccount, additionalTag ...string) *SpamBuilder
func (*SpamBuilder) AddInput ¶ added in v1.0.0
func (b *SpamBuilder) AddInput(input UTXOInterface, opts ...AddInputOption) bool
AddInput checks if the given input would fit in the transaction and it them if possible.
func (*SpamBuilder) AddOutput ¶ added in v1.0.0
func (b *SpamBuilder) AddOutput(output iotago.Output, opts ...AddOutputOption) bool
AddOutput adds the given output to the transaction.
func (*SpamBuilder) AddOutputWithOwnership ¶ added in v1.0.0
func (b *SpamBuilder) AddOutputWithOwnership(output iotago.Output, ownedOutputs []*UTXO, opts ...AddOutputOption) bool
AddOutput adds the given output to the transaction.
func (*SpamBuilder) Clone ¶ added in v1.0.0
func (b *SpamBuilder) Clone() *SpamBuilder
func (*SpamBuilder) ConsumedInputsEmpty ¶ added in v1.0.0
func (b *SpamBuilder) ConsumedInputsEmpty() bool
func (*SpamBuilder) InputConsumed ¶ added in v1.0.0
func (b *SpamBuilder) InputConsumed(outputID iotago.OutputID) bool
InputConsumed checks if the given input is already consumed.
type Spammer ¶
type Spammer struct { // the logger used to log events. *logger.WrappedLogger syncutils.RWMutex Events *Events // contains filtered or unexported fields }
Spammer is used to issue blocks to the IOTA network to create load on the tangle.
func New ¶
func New( protocolParametersFunc ProtocolParametersFunc, indexer nodeclient.IndexerClient, wallet *hdwallet.HDWallet, bpsRateLimit float64, cpuMaxUsage float64, workersCount int, message string, tag string, tagSemiLazy string, valueSpamEnabled bool, valueSpamSendBasicOutput bool, valueSpamCollectBasicOutput bool, valueSpamCreateAlias bool, valueSpamDestroyAlias bool, valueSpamCreateFoundry bool, valueSpamDestroyFoundry bool, valueSpamMintNativeToken bool, valueSpamMeltNativeToken bool, valueSpamCreateNFT bool, valueSpamDestroyNFT bool, nonLazyTipsThreshold uint32, semiLazyTipsThreshold uint32, refreshTipsInterval time.Duration, getTipsPoolSizesFunc GetTipsPoolSizesFunc, requestTipsFunc RequestTipsFunc, isNodeHealthyFunc IsNodeHealthyFunc, sendBlockFunc SendBlockFunc, blockMetadataFunc BlockMetadataFunc, spammerMetrics *Metrics, cpuUsageUpdater *CPUUsageUpdater, daemon hivedaemon.Daemon, log *logger.Logger) (*Spammer, error)
New creates a new spammer instance.
func (*Spammer) ApplyNewLedgerUpdate ¶ added in v1.0.0
func (s *Spammer) ApplyNewLedgerUpdate(ctx context.Context, msIndex iotago.MilestoneIndex, createdOutputs iotago.OutputIDs, consumedOutputs iotago.OutputIDs) error
ApplyNewLedgerUpdate applies a new ledger update to the spammer. If a conflict is found, the spammer ledger state is rebuild by querying the indexer.
func (*Spammer) BPSRateLimitRunning ¶
func (*Spammer) BuildTaggedDataBlockAndSend ¶ added in v1.0.0
func (*Spammer) BuildTransactionPayloadBlockAndSend ¶ added in v1.0.0
func (s *Spammer) BuildTransactionPayloadBlockAndSend(ctx context.Context, spamBuilder *SpamBuilder) ([]UTXOInterface, *UTXO, error)
func (*Spammer) CPUMaxUsageRunning ¶
func (*Spammer) IsValueSpamEnabled ¶ added in v1.0.0
func (*Spammer) MeasureSpammerMetrics ¶
func (s *Spammer) MeasureSpammerMetrics()
measureSpammerMetrics measures the spammer metrics.