Skip to content

Conversation

@tosettil-polimi
Copy link

@tosettil-polimi tosettil-polimi commented Jun 24, 2025

Extract peer and target

Refactor Tx Load Tool: Modularize Load Target and Peer Logic

Description:

This PR refactors the transaction load testing tool to improve modularity, maintainability, and separation of concerns. The main changes include:

  • Modularized logic for transaction generation and sending:

    • Introduced LoadTarget in a new file (load_target.go) to encapsulate wallet and transaction handling.
    • Introduced Peer abstraction (peer.go) for managing P2P connections and reading transaction messages.
  • ♻️ Moved and cleaned up logic from tx_load_tool.go:

    • Removed inline transaction generation and P2P connection logic from the Load struct.
    • Added a dedicated generateAndSendTx method for clarity and error handling.
    • Replaced custom TCP connection logic with the Peer abstraction for better encapsulation.
  • 🧹 Code simplifications and minor cleanups:

    • Removed redundant code.
    • Updated comments and renamed variables for clarity.
    • Changed var errDisc error = ... to idiomatic var errDisc = ....

Why?

  • Improves readability and testability of load testing logic.
  • Makes the transaction load module easier to extend and maintain.
  • Prepares codebase for future enhancements (e.g. multiple peers, dynamic load patterns).

No functional changes expected

This is a pure refactor. Functional behavior remains the same.

@tosettil-polimi tosettil-polimi merged commit 2efc303 into master Jun 24, 2025
1 check passed
@tosettil-polimi tosettil-polimi deleted the extract_peer_and_target branch June 24, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants