@@ -3,85 +3,85 @@ package generator
33import (
44 "sync"
55
6- "seiload /config"
7- "seiload /generator/scenarios"
8- "seiload /types"
6+ "github.com/sei-protocol/sei-load /config"
7+ "github.com/sei-protocol/sei-load /generator/scenarios"
8+ "github.com/sei-protocol/sei-load /types"
99)
1010
1111// PrewarmGenerator generates self-transfer transactions to prewarm account nonces
1212type PrewarmGenerator struct {
13- accountPools []types.AccountPool
14- evmScenario scenarios.TxGenerator
15- currentPoolIdx int
16- finished bool
17- mu sync.RWMutex
13+ accountPools []types.AccountPool
14+ evmScenario scenarios.TxGenerator
15+ currentPoolIdx int
16+ finished bool
17+ mu sync.RWMutex
1818}
1919
2020// NewPrewarmGenerator creates a new prewarm generator using all account pools from the main generator
2121func NewPrewarmGenerator (config * config.LoadConfig , mainGenerator Generator ) * PrewarmGenerator {
2222 // Get all account pools from the main generator
2323 accountPools := mainGenerator .GetAccountPools ()
24-
24+
2525 // Create EVMTransfer scenario for prewarming
2626 evmScenario := scenarios .NewEVMTransferScenario ()
27-
27+
2828 // Deploy/initialize the scenario (EVMTransfer doesn't need actual deployment)
2929 deployerAccounts := types .GenerateAccounts (1 )
3030 deployer := deployerAccounts [0 ]
3131 evmScenario .Deploy (config , deployer )
32-
32+
3333 return & PrewarmGenerator {
34- accountPools : accountPools ,
35- evmScenario : evmScenario ,
34+ accountPools : accountPools ,
35+ evmScenario : evmScenario ,
3636 currentPoolIdx : 0 ,
37- finished : false ,
37+ finished : false ,
3838 }
3939}
4040
4141// Generate generates self-transfer transactions until all accounts are prewarmed
4242func (pg * PrewarmGenerator ) Generate () (* types.LoadTx , bool ) {
4343 pg .mu .Lock ()
4444 defer pg .mu .Unlock ()
45-
45+
4646 // Check if we're already finished
4747 if pg .finished || pg .currentPoolIdx >= len (pg .accountPools ) {
4848 return nil , false
4949 }
50-
50+
5151 // Get current pool
5252 currentPool := pg .accountPools [pg .currentPoolIdx ]
5353 account := currentPool .NextAccount ()
54-
54+
5555 // If this account has nonce > 0, we've already prewarmed it (round-robin means we're done with this pool)
5656 if account .Nonce > 0 {
5757 // Move to next pool
5858 pg .currentPoolIdx ++
59-
59+
6060 // Check if we've finished all pools
6161 if pg .currentPoolIdx >= len (pg .accountPools ) {
6262 pg .finished = true
6363 return nil , false
6464 }
65-
65+
6666 // Get account from next pool
6767 currentPool = pg .accountPools [pg .currentPoolIdx ]
6868 account = currentPool .NextAccount ()
69-
69+
7070 // If this account also has nonce > 0, we're completely done
7171 if account .Nonce > 0 {
7272 pg .finished = true
7373 return nil , false
7474 }
7575 }
76-
76+
7777 // Create self-transfer transaction
7878 scenario := & types.TxScenario {
7979 Name : "EVMTransfer" ,
8080 Sender : account ,
8181 Receiver : account .Address , // Send to self
8282 Nonce : account .GetAndIncrementNonce (),
8383 }
84-
84+
8585 // Generate the transaction using EVMTransfer scenario
8686 return pg .evmScenario .Generate (scenario ), true
8787}
@@ -103,7 +103,7 @@ func (pg *PrewarmGenerator) GenerateN(n int) []*types.LoadTx {
103103func (pg * PrewarmGenerator ) GetAccountPools () []types.AccountPool {
104104 pg .mu .RLock ()
105105 defer pg .mu .RUnlock ()
106-
106+
107107 // Return a copy to prevent external modification
108108 pools := make ([]types.AccountPool , len (pg .accountPools ))
109109 copy (pools , pg .accountPools )
0 commit comments