Skip to content

Commit 79ceb83

Browse files
authored
Merge pull request #198 from ethpandaops/pk910/fix-wallet-initilitzation-panic
fix wallet initilitzation panic
2 parents de6c570 + df89aa2 commit 79ceb83

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

spamoor/wallet.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ func (wallet *Wallet) IncrementSubmittedTxCount() {
197197
func (wallet *Wallet) GetBalance() *big.Int {
198198
wallet.balanceMutex.RLock()
199199
defer wallet.balanceMutex.RUnlock()
200+
if wallet.balance == nil {
201+
return new(big.Int)
202+
}
200203
return wallet.balance
201204
}
202205

spamoor/walletpool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,12 @@ func (pool *WalletPool) prepareWallet(privkey string, client *Client, refillAmou
628628
}
629629

630630
// Set up low balance notification
631-
if pool.runFundings {
631+
if pool.runFundings && refillBalance != nil {
632632
childWallet.setLowBalanceNotification(pool.lowBalanceNotifyChan, refillBalance.ToBig())
633633
}
634634

635635
var fundingReq *FundingRequest
636-
if pool.runFundings && childWallet.GetBalance().Cmp(refillBalance.ToBig()) < 0 {
636+
if pool.runFundings && refillBalance != nil && childWallet.GetBalance().Cmp(refillBalance.ToBig()) < 0 {
637637
currentBalance := uint256.MustFromBig(childWallet.GetBalance())
638638
fundingReq = &FundingRequest{
639639
Wallet: childWallet,
@@ -777,7 +777,7 @@ func (pool *WalletPool) resupplyChildWallets() error {
777777
return
778778
}
779779

780-
if childWallet.GetBalance().Cmp(refillBalance.ToBig()) < 0 {
780+
if refillBalance != nil && childWallet.GetBalance().Cmp(refillBalance.ToBig()) < 0 {
781781
currentBalance := uint256.MustFromBig(childWallet.GetBalance())
782782
reqsMutex.Lock()
783783
fundingReqs = append(fundingReqs, &FundingRequest{
@@ -807,7 +807,7 @@ func (pool *WalletPool) resupplyChildWallets() error {
807807
walletErr = err
808808
return
809809
}
810-
if childWallet.GetBalance().Cmp(pool.config.RefillBalance.ToBig()) < 0 {
810+
if pool.config.RefillBalance != nil && childWallet.GetBalance().Cmp(pool.config.RefillBalance.ToBig()) < 0 {
811811
currentBalance := uint256.MustFromBig(childWallet.GetBalance())
812812
reqsMutex.Lock()
813813
fundingReqs = append(fundingReqs, &FundingRequest{
@@ -1128,7 +1128,7 @@ func (pool *WalletPool) CheckChildWalletBalance(childWallet *Wallet) error {
11281128
}
11291129
}
11301130

1131-
if childWallet.GetBalance().Cmp(refillBalance.ToBig()) >= 0 {
1131+
if refillBalance == nil || childWallet.GetBalance().Cmp(refillBalance.ToBig()) >= 0 {
11321132
return nil
11331133
}
11341134

webui/templates/index/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ <h5 class="modal-title">Edit Spammer</h5>
676676
}
677677

678678
/* Load configuration */
679-
const config = await fetch(`/api/scenarios/${scenarioName}/config`).then(r => r.text());
679+
const config = await spamoor.authFetch(`/api/scenarios/${scenarioName}/config`).then(r => r.text());
680680
document.querySelector('#newSpammerForm [name="config"]').value = config;
681681
}
682682

0 commit comments

Comments
 (0)