Skip to content

feat(bitswap): add option to disable Bitswap server #911

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

Merged
merged 9 commits into from
Apr 30, 2025

Conversation

gystemd
Copy link
Contributor

@gystemd gystemd commented Apr 17, 2025

Follow-up from feat(config): ability to disable Bitswap fully or just server #10782
This pull request introduces the ability to enable or disable the server functionality in the Bitswap component, along with associated updates to the codebase and new tests. The changes ensure that Bitswap can operate in a client-only mode when the server is disabled, while maintaining backward compatibility.

Core functionality changes:

  • Added a serverEnabled field to the Bitswap struct, defaulting to true, and updated the New function to conditionally initialize the server based on this flag.
  • Modified methods such as Stat, NotifyNewBlocks, PeerConnected, and PeerDisconnected to handle cases where the server is disabled, ensuring no server-related operations are performed in this mode.

New configuration option:

  • Introduced a WithServerEnabled option to allow users to explicitly enable or disable the server when creating a Bitswap instance.

Testing enhancements:

  • Added a new test, TestWithServerDisabled, to verify that Bitswap operates correctly in client-only mode, including requesting blocks, handling Stat output, and ensuring no responses to incoming requests.
  • Added TestServerDisabledNotifyNewBlocks to confirm that the NotifyNewBlocks method works as expected when the server is disabled.

@gammazero gammazero marked this pull request as ready for review April 29, 2025 14:07
@gammazero gammazero requested a review from a team as a code owner April 29, 2025 14:07
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