Skip to content

Remove redundant map, simplify code; Show status and allow mouse click to peer to connect#21

Merged
ldemailly merged 4 commits intomainfrom
cleanup
Oct 22, 2025
Merged

Remove redundant map, simplify code; Show status and allow mouse click to peer to connect#21
ldemailly merged 4 commits intomainfrom
cleanup

Conversation

@ldemailly
Copy link
Copy Markdown
Member

No description provided.

@ldemailly ldemailly requested a review from Copilot October 22, 2025 16:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the redundant connections map and consolidates connection tracking directly into the Peers map by embedding connection status and address fields within PeerData. The refactoring simplifies the codebase by eliminating duplicate data structures while maintaining the same functionality.

Key changes:

  • Removed the Connection struct and connections map from the Server struct
  • Added Status and Addr fields to PeerData to track connection state
  • Updated ConnectToPeer to store connection status directly in Peers map

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tsnet/tsnet.go Removed Connection struct and connections map; moved connection tracking fields (Status, Addr) into PeerData; updated ConnectToPeer to use consolidated Peers map
tsnet/tsnet_test.go Updated test to access connection status via Peers map instead of removed Connections() method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 10.34483% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.86%. Comparing base (2e4274a) to head (a090146).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
main.go 0.00% 48 Missing ⚠️
tsnet/tsnet.go 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
- Coverage   54.59%   50.86%   -3.73%     
==========================================
  Files           9        9              
  Lines         784      812      +28     
==========================================
- Hits          428      413      -15     
- Misses        314      357      +43     
  Partials       42       42              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldemailly ldemailly requested a review from Copilot October 22, 2025 16:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +54 to 57
NotLinked ConnectionStatus = iota
Connecting
Connected
Disconnected
Failed
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConnectionStatus constants lack documentation. Add a comment block explaining each state (NotLinked, Connecting, Connected, Failed) to clarify when each status is used, especially since NotLinked is now the zero value.

Copilot uses AI. Check for mistakes.
@ldemailly ldemailly changed the title Remove redundant map, simplify code Remove redundant map, simplify code; Show status and allow mouse click to peer to connect Oct 22, 2025
@ldemailly ldemailly requested a review from Copilot October 22, 2025 17:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

tsnet/tsnet.go Outdated
log.S(log.Verbose, "Already known peer", log.Any("Peer", peer), log.Any("OldData", v), log.Any("NewData", data))
// transfer the human hash (same pub key so same human hash)
data.HumanHash = v.HumanHash
// And the status
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected grammar in comment from 'And the status' to 'Transfer the status'.

Suggested change
// And the status
// transfer the status

Copilot uses AI. Check for mistakes.
main.go Outdated
Comment on lines +172 to +176
ap.OnMouse = func() {
if !ap.LeftClick() || !ap.MouseRelease() {
return
}
line := ap.My - 4 // account for our line and header
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 4 used for offset calculation lacks explanation. Consider defining a named constant (e.g., headerOffset = 4) or expanding the comment to clarify what components make up this offset (e.g., 'account for status line, header line, and 2 lines of padding').

Suggested change
ap.OnMouse = func() {
if !ap.LeftClick() || !ap.MouseRelease() {
return
}
line := ap.My - 4 // account for our line and header
// Offset for mouse line calculation:
// 1 line for status, 1 line for header, and 2 lines of padding.
const headerOffset = 4
ap.OnMouse = func() {
if !ap.LeftClick() || !ap.MouseRelease() {
return
}
line := ap.My - headerOffset // account for status line, header line, and 2 lines of padding

Copilot uses AI. Check for mistakes.
@ldemailly ldemailly requested a review from Copilot October 22, 2025 18:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ldemailly ldemailly merged commit 02580a6 into main Oct 22, 2025
7 of 9 checks passed
@ldemailly ldemailly deleted the cleanup branch October 22, 2025 18:04
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.

2 participants