Skip to content

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
@gammazero gammazero merged commit f54c309 into ipfs:main Apr 30, 2025
11 checks passed
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