Skip to content

Commit

Permalink
Allow serving snap without having snap sync enabled (#6806)
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap authored Mar 5, 2024
1 parent bee4dde commit fdc62b0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,11 @@ await InitPeer().ContinueWith(initPeerTask =>
}
});

if (_syncConfig.SnapSync)
if (_syncConfig.SnapSync && !_syncConfig.SnapServingEnabled)
{
if (!_syncConfig.SnapServingEnabled)
{
// TODO: Should we keep snap capability even after finishing sync?
SnapCapabilitySwitcher snapCapabilitySwitcher =
new(_api.ProtocolsManager, _api.SyncModeSelector, _api.LogManager);
snapCapabilitySwitcher.EnableSnapCapabilityUntilSynced();
}
else
{
_api.ProtocolsManager!.AddSupportedCapability(new Capability(Protocol.Snap, 1));
}
SnapCapabilitySwitcher snapCapabilitySwitcher =
new(_api.ProtocolsManager, _api.SyncModeSelector, _api.LogManager);
snapCapabilitySwitcher.EnableSnapCapabilityUntilSynced();
}

else if (_logger.IsDebug) _logger.Debug("Skipped enabling snap capability");
Expand Down Expand Up @@ -536,6 +528,11 @@ private async Task InitPeer()
_api.LogManager,
_api.TxGossipPolicy);

if (_syncConfig.SnapServingEnabled)
{
_api.ProtocolsManager!.AddSupportedCapability(new Capability(Protocol.Snap, 1));
}

if (_syncConfig.WitnessProtocolEnabled)
{
_api.ProtocolsManager.AddSupportedCapability(new Capability(Protocol.Wit, 0));
Expand Down

0 comments on commit fdc62b0

Please sign in to comment.