Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor P2P.connected? into Connection module #1100

Conversation

Neylix
Copy link
Member

@Neylix Neylix commented Jun 15, 2023

Description

Refactor to be ready for hot reload

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Neylix Neylix added this to the 1.1.2 milestone Jun 15, 2023
@@ -11,11 +11,20 @@ defmodule Archethic.P2P.Supervisor do

use Supervisor

@table_name :connection_status
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you should use a function in the Connection module to give the name of the table.

def start_link(args \\ []) do
Supervisor.start_link(__MODULE__, args, name: Archethic.P2PSupervisor)
end

def init(_args) do
# Start an ets table to manage node connection status.
# This reduce the number of message sent to the Connection GenServer
if :ets.whereis(@table_name) == :undefined do
Copy link
Member

@samuelmanzanera samuelmanzanera Jun 15, 2023

Choose a reason for hiding this comment

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

If we want to be cleaner, the best would be use a dedicated to connection information or status and might manage its own state and lifecycle.

@samuelmanzanera samuelmanzanera merged commit e73c45b into archethic-foundation:1.1.2 Jun 19, 2023
1 check passed
@Neylix Neylix deleted the Fix-connection-infos-overwrite branch June 19, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants