From fdc62b0c36a76f90f83326100e5a5f8ef89fe8a3 Mon Sep 17 00:00:00 2001 From: Amirul Ashraf Date: Tue, 5 Mar 2024 13:35:48 +0800 Subject: [PATCH] Allow serving snap without having snap sync enabled (#6806) --- .../Steps/InitializeNetwork.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs b/src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs index faa3742db87..e17a9d2bb9b 100644 --- a/src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs +++ b/src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs @@ -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"); @@ -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));