Skip to content

Track deferred cleanup items from PR #2125 #2129

@sanity

Description

@sanity

Overview

Tracking deferred code cleanup items from PR #2125 review to ensure they don't get lost in follow-up work.

Background

During review of the transient connection handling changes, several code quality issues were intentionally left unchanged to minimize churn in the PR slice. This issue tracks those items for systematic follow-up.

Reference: #2125 (comment)

Deferred Items

1. Dead Code Annotations

File: crates/core/src/ring/connection_manager.rs

Remove unused #[allow(dead_code)] annotations on helper methods:

  • get_open_connections()
  • get_reserved_connections()

These were marked to avoid compilation warnings but may indicate methods that should be removed entirely or need better documentation of their purpose.

2. Redundant Pending Reservation Logic

File: crates/core/src/ring/connection_manager.rs

The should_accept() method inserts peers into pending_reservations before the acceptance decision completes. This creates potential duplicate tracking:

  • Line ~184: Initial insertion during acceptance check
  • Line ~244: Second insertion via record_pending_location()

Review if both insertions are necessary or if logic can be simplified.

3. Double Removal During Rejection

File: crates/core/src/ring/connection_manager.rs

In add_connection(), when a connection is rejected due to cap enforcement, the peer is removed from pending_reservations twice:

  • Once in the rejection path
  • Again during rollback cleanup

Consolidate removal logic to avoid redundant operations.

4. Logging Verbosity

File: crates/core/src/node/network_bridge/p2p_protoc.rs

Routing candidate selection logs at info! level cause log flooding during normal operation. Downgrade to debug! or trace! to reduce noise.

5. Public Key Display Format

File: crates/core/src/node/network_bridge/p2p_protoc.rs (and related)

SHA256 hash representation for public keys made logs unreadable. Reverted to shortened base58 encoding in this PR, but review if consistent display format should be used project-wide.

6. Test Harness Dependency

Related issue: #2082

Soak and cap regression tests rely on out-of-tree freenet-test-network crate. Resolve whether to:

  • Inline necessary test utilities into freenet-core
  • Move freenet-test-network into the main repo
  • Keep as external dependency with explicit justification

See also: #2125 (comment)

Priority

These are code quality improvements, not critical bugs. Can be addressed incrementally in follow-up PRs.

Success Criteria

  • All #[allow(dead_code)] removed or justified with comments
  • Pending reservation logic simplified to single insertion point
  • No redundant removals during rollback
  • Routing logs produce reasonable output volume at default log level
  • Consistent public key display format documented
  • Test harness strategy documented and consensus reached

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-developer-xpArea: developer experienceA-networkingArea: Networking, ring protocol, peer discoveryE-mediumExperience needed to fix/implement: Medium / intermediateT-trackingType: Meta-issue tracking multiple related issues

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions