load

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistributeFunds

func DistributeFunds(ctx context.Context, client ethclient.Client, keys []*key.Key, numKeys int, minFundsPerAddr *big.Int) ([]*key.Key, error)

DistributeFunds ensures that each address in keys has at least [minFundsPerAddr] by sending funds from the key with the highest starting balance. This function returns a set of at least [numKeys] keys, each having a minimum balance [minFundsPerAddr].

func ExecuteLoader

func ExecuteLoader(ctx context.Context, config config.Config) error

ExecuteLoader runs the load simulation specified by config.

func GenerateTxSequence

func GenerateTxSequence(ctx context.Context, generator CreateTx, client ethclient.Client, key *ecdsa.PrivateKey, numTxs uint64) ([]*types.Transaction, error)

GenerateTxSequence fetches the current nonce of key and calls [generator] [numTxs] times sequentially to generate a sequence of transactions.

func GenerateTxSequences

func GenerateTxSequences(ctx context.Context, generator CreateTx, client ethclient.Client, keys []*ecdsa.PrivateKey, txsPerKey uint64) ([][]*types.Transaction, error)

Types

type CreateTx

type CreateTx func(key *ecdsa.PrivateKey, nonce uint64) (*types.Transaction, error)

type Worker

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

func NewWorker

func NewWorker(client ethclient.Client, address common.Address, txs []*types.Transaction) *Worker

NewWorker creates a new worker that will issue the sequence of transactions from the given address

Assumes that all transactions are from the same address, ordered by nonce, and this worker has exclusive access to issuance of transactions from the underlying private key.

func (*Worker) AwaitTxs

func (w *Worker) AwaitTxs(ctx context.Context) error

AwaitTxs awaits for the nonce of the last transaction issued by the worker to be confirmed or rejected by the network.

Assumes that a non-zero number of transactions were already generated and that they were issued by this worker.

func (*Worker) ConfirmAllTransactions

func (w *Worker) ConfirmAllTransactions(ctx context.Context) error

ConfirmAllTransactions iterates over every transaction of this worker and confirms it via eth_getTransactionByHash

func (*Worker) Execute

func (w *Worker) Execute(ctx context.Context) error

Execute issues and confirms all transactions for the worker.

func (*Worker) ExecuteTxsFromAddress

func (w *Worker) ExecuteTxsFromAddress(ctx context.Context) error

type WorkerGroup

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

func CreateLoader

func CreateLoader(ctx context.Context, config config.Config) (*WorkerGroup, error)

CreateLoader creates a WorkerGroup from config to perform the specified simulation.

func NewWorkerGroup

func NewWorkerGroup(clients []ethclient.Client, senders []common.Address, txSequences [][]*types.Transaction) *WorkerGroup

func (*WorkerGroup) AwaitTxs

func (wg *WorkerGroup) AwaitTxs(ctx context.Context) error

AwaitTxs concurrently waits for each worker to confirm the nonce of its last issued transaction.

func (*WorkerGroup) ConfirmAllTransactions

func (wg *WorkerGroup) ConfirmAllTransactions(ctx context.Context) error

ConfirmAllTransactions concurrently waits for each worker to confirm each transaction by checking for it via eth_getTransactionByHash

func (*WorkerGroup) Execute

func (wg *WorkerGroup) Execute(ctx context.Context) error

Execute performs executes the following steps in order: - IssueTxs - AwaitTxs - ConfirmAllTransactions

func (*WorkerGroup) IssueTxs

func (wg *WorkerGroup) IssueTxs(ctx context.Context) error

IssueTxs concurrently issues transactions from each worker

Jump to

Keyboard shortcuts

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