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 ocean node, clean commands + handlers #197

Merged
merged 12 commits into from
Jan 10, 2024

Conversation

paulo-ocean
Copy link
Contributor

@paulo-ocean paulo-ocean commented Jan 3, 2024

Fixes #181

Changes proposed in this PR:

  • Clean handlers classes + protocol commands usage, refactor OceanNode class and a little bit on the handlers

  • Main changes:

  • new class CoreHandlersRegistry. its used to register all core handlers (easy to add more on demand). Some helper methods on the same file. Singleton instance.

  • Ocean Node has a property of this type (coreHandlers), which is used to get the correct handler for a given Command. Basically uses the Singleton above.

No more switch / case.. just get the handler from the OceanNode or Singleton (see handleDirectProtocolCommands and handleProtocolCommands)

  • Moved all the logger instances that were scattered within multiple files, to a single file under: /utils/logging/common.js . Its easier to keep track of them and avoids issues with dependency cycling

(Note: There are many files changed but in most cases it was just these "Logger" related imports)

@paulo-ocean paulo-ocean changed the title wip: refactor commands, cleaning handlers wip: refactor ocean node, clean commands + handlers Jan 3, 2024
@paulo-ocean paulo-ocean self-assigned this Jan 3, 2024
@paulo-ocean paulo-ocean marked this pull request as ready for review January 4, 2024 17:52
@alexcos20 alexcos20 changed the title wip: refactor ocean node, clean commands + handlers refactor ocean node, clean commands + handlers Jan 9, 2024
Copy link
Member

@bogdanfazakas bogdanfazakas left a comment

Choose a reason for hiding this comment

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

lgtm, some minor questions but not critical or urgent

src/components/P2P/index.ts Show resolved Hide resolved
src/utils/constants.ts Show resolved Hide resolved
Copy link
Member

@jamiehewitt15 jamiehewitt15 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@paulo-ocean paulo-ocean merged commit fd42a74 into develop Jan 10, 2024
6 checks passed
@paulo-ocean paulo-ocean deleted the issue-181-node-hander-refactor branch January 10, 2024 15:24
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.

5 participants