@@ -65,6 +65,7 @@ func init() {
6565 rootCmd .Flags ().String ("metricsListenAddr" , "0.0.0.0:9090" , "The ip:port on which to export prometheus metrics." )
6666 rootCmd .Flags ().Bool ("ramp-up" , false , "Ramp up loadtest" )
6767 rootCmd .Flags ().String ("report-path" , "" , "Path to save the report" )
68+ rootCmd .Flags ().String ("txs-dir" , "" , "Path to save the transactions" )
6869
6970 // Initialize Viper with proper error handling
7071 if err := config .InitializeViper (rootCmd ); err != nil {
@@ -169,12 +170,6 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
169170 sharedLimiter = rate .NewLimiter (rate .Inf , 1 )
170171 }
171172
172- // Create the sender from the config struct
173- snd , err := sender .NewShardedSender (cfg , settings .BufferSize , settings .Workers , sharedLimiter )
174- if err != nil {
175- return fmt .Errorf ("failed to create sender: %w" , err )
176- }
177-
178173 // Create and start block collector if endpoints are available
179174 var blockCollector * stats.BlockCollector
180175 if len (cfg .Endpoints ) > 0 && settings .TrackBlocks {
@@ -207,6 +202,12 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
207202 })
208203 }
209204
205+ // Create the sender from the config struct
206+ snd , err := sender .NewShardedSender (cfg , settings .BufferSize , settings .Workers , sharedLimiter )
207+ if err != nil {
208+ return fmt .Errorf ("failed to create sender: %w" , err )
209+ }
210+
210211 // Enable dry-run mode in sender if specified
211212 if settings .DryRun {
212213 snd .SetDryRun (true )
@@ -225,7 +226,13 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
225226 snd .SetStatsCollector (collector , logger )
226227
227228 // Create dispatcher
228- dispatcher := sender .NewDispatcher (gen , snd )
229+ var dispatcher * sender.Dispatcher
230+ if settings .TxsDir != "" {
231+ writer := sender .NewTxsWriter (10_000_000 , settings .TxsDir )
232+ dispatcher = sender .NewDispatcher (gen , writer )
233+ } else {
234+ dispatcher = sender .NewDispatcher (gen , snd )
235+ }
229236
230237 // Set statistics collector for dispatcher
231238 dispatcher .SetStatsCollector (collector )
@@ -239,10 +246,11 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
239246 log .Printf ("📝 Prewarm mode: Accounts will be prewarmed" )
240247 }
241248
242- // Start the sender (starts all workers)
243- s .SpawnBgNamed ("sender" , func () error { return snd .Run (ctx ) })
244- log .Printf ("✅ Connected to %d endpoints" , snd .GetNumShards ())
245-
249+ if settings .TxsDir == "" {
250+ // Start the sender (starts all workers)
251+ s .SpawnBgNamed ("sender" , func () error { return snd .Run (ctx ) })
252+ log .Printf ("✅ Connected to %d endpoints" , snd .GetNumShards ())
253+ }
246254 // Perform prewarming if enabled (before starting logger to avoid logging prewarm transactions)
247255 if settings .Prewarm {
248256 if err := dispatcher .Prewarm (ctx ); err != nil {
0 commit comments