Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Nethermind/Nethermind.Xdc/XdcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using Nethermind.Evm.TransactionProcessing;
using Nethermind.Xdc.TxPool;
using Nethermind.Api.Steps;
using Nethermind.Synchronization.FastSync;
using Nethermind.Synchronization.ParallelSync;

namespace Nethermind.Xdc;

Expand Down Expand Up @@ -93,6 +95,9 @@ protected override void Load(ContainerBuilder builder)

// block processing
.AddScoped<ITransactionProcessor, XdcTransactionProcessor>()

// state sync allocation strategy - override default to use protocol version 100 check
.AddSingleton<IPeerAllocationStrategyFactory<StateSyncBatch>, XdcStateSyncAllocationStrategyFactory>()
;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Stats;
using Nethermind.Synchronization.FastSync;
using Nethermind.Synchronization.ParallelSync;
using Nethermind.Synchronization.Peers;
using Nethermind.Synchronization.Peers.AllocationStrategies;
using Nethermind.Synchronization.StateSync;

namespace Nethermind.Xdc;

public class XdcStateSyncAllocationStrategyFactory : StaticPeerAllocationStrategyFactory<StateSyncBatch>
{
private static readonly IPeerAllocationStrategy DefaultStrategy =
new AllocationStrategy(new BySpeedStrategy(TransferSpeedType.NodeData, true));

public XdcStateSyncAllocationStrategyFactory() : base(DefaultStrategy)
{
}

internal class AllocationStrategy : FilterPeerAllocationStrategy
{
public AllocationStrategy(IPeerAllocationStrategy strategy) : base(strategy)
{
}

protected override bool Filter(PeerInfo peerInfo)
{
return peerInfo.CanGetSnapData() || peerInfo.SyncPeer.ProtocolVersion == 100;
}
}
}