Documentation
¶
Index ¶
- Variables
- type AccountStatus
- type Client
- type Config
- type DistributionResult
- type Distributor
- func (d *Distributor) Distribute(ctx context.Context, masterKey *ecdsa.PrivateKey, subAccounts []common.Address) (*DistributionResult, error)
- func (d *Distributor) GetAccountNonces(ctx context.Context, accounts []*AccountStatus) ([]uint64, error)
- func (d *Distributor) WaitForFunding(ctx context.Context, accounts []*AccountStatus, timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInsufficientFunds = errors.New("insufficient distributor funds") ErrNoAccountsToFund = errors.New("no accounts to fund") )
Functions ¶
This section is empty.
Types ¶
type AccountStatus ¶
type AccountStatus struct {
Address common.Address
Balance *big.Int
RequiredFund *big.Int
MissingFund *big.Int
Nonce uint64
IsFunded bool
}
AccountStatus represents the funding status of an account
type Client ¶
type Client interface {
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
SuggestGasPrice(ctx context.Context) (*big.Int, error)
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
SendTransaction(ctx context.Context, tx *types.Transaction) error
ChainID(ctx context.Context) (*big.Int, error)
}
Client interface for blockchain operations
type Config ¶
type Config struct {
// Amount of gas each sub-account needs per transaction
GasPerTx uint64
// Number of transactions each sub-account will send
TxsPerAccount int
// Gas price for calculations
GasPrice *big.Int
// Extra buffer percentage (e.g., 10 for 10% extra)
BufferPercent int
}
Config holds distribution configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default distribution configuration
func (*Config) CalculateRequiredFund ¶
CalculateRequiredFund calculates the required fund for an account
type DistributionResult ¶
type DistributionResult struct {
// Accounts that are ready for stress test
ReadyAccounts []*AccountStatus
// Accounts that could not be funded
UnfundedAccounts []*AccountStatus
// Total amount distributed
TotalDistributed *big.Int
// Number of distribution transactions sent
TxCount int
}
DistributionResult holds the result of fund distribution
type Distributor ¶
type Distributor struct {
// contains filtered or unexported fields
}
Distributor manages fund distribution from master to sub-accounts
func New ¶
func New(client Client, config *Config) *Distributor
New creates a new Distributor instance
func (*Distributor) Distribute ¶
func (d *Distributor) Distribute( ctx context.Context, masterKey *ecdsa.PrivateKey, subAccounts []common.Address, ) (*DistributionResult, error)
Distribute distributes funds from the master account to sub-accounts
func (*Distributor) GetAccountNonces ¶
func (d *Distributor) GetAccountNonces( ctx context.Context, accounts []*AccountStatus, ) ([]uint64, error)
GetAccountNonces fetches the current nonce for each account
func (*Distributor) WaitForFunding ¶
func (d *Distributor) WaitForFunding( ctx context.Context, accounts []*AccountStatus, timeout time.Duration, ) error
WaitForFunding waits for all distribution transactions to be confirmed
Click to show internal directories.
Click to hide internal directories.