Documentation
¶
Index ¶
Constants ¶
const SecondsPerSlot uint64 = 12
Variables ¶
This section is empty.
Functions ¶
func RunTransactionScenario ¶
func RunTransactionScenario(ctx context.Context, options TransactionScenarioOptions) error
RunTransactionScenario executes a controlled transaction scenario with rate limiting and concurrency management. It processes transactions according to the specified options until either context cancellation or reaching TotalCount (if > 0).
Features: - Rate-limited execution based on Throughput - Optional dynamic throughput increases - Concurrency control via MaxPending - Sequential logging via transaction chaining
Returns an error only if the scenario cannot be started. Transaction failures should be handled within ProcessNextTxFn.
Types ¶
type Descriptor ¶
type Descriptor struct {
Name string
Description string
DefaultOptions any
NewScenario func(logger logrus.FieldLogger) Scenario
}
Descriptor describes a scenario.
type Options ¶
type Options struct {
WalletPool *spamoor.WalletPool
Config string
GlobalCfg map[string]any
}
Options contains the options for the scenario initialization.
type TransactionScenarioOptions ¶
type TransactionScenarioOptions struct {
TotalCount uint64
Throughput uint64
MaxPending uint64
ThroughputIncrementInterval uint64
Timeout time.Duration // Maximum duration for scenario execution (0 = no timeout)
WalletPool *spamoor.WalletPool
NoAwaitTransactions bool // If true, the scenario will not wait for transactions to be included in a block
// Logger for scenario execution information
Logger *logrus.Entry
// ProcessNextTxFn handles transaction execution with the given index
// It should return:
// - A callback function to log transaction results (can be nil)
// - An error if transaction creation failed
// - The onComplete callback must be called when transaction processing is complete
ProcessNextTxFn func(ctx context.Context, txIdx uint64, onComplete func()) (func(), error)
}
TransactionScenarioOptions configures how the transaction scenario is executed.