diff --git a/pkg/protocol/chains.go b/pkg/protocol/chains.go index 9704fca55..97af7125f 100644 --- a/pkg/protocol/chains.go +++ b/pkg/protocol/chains.go @@ -55,7 +55,7 @@ func newChains(protocol *Protocol) *Chains { shutdown := lo.Batch( c.initLogger(protocol.NewChildLogger("Chains")), - c.initChainSwitching(protocol.Options.ChainSwitchingThreshold), + c.initChainSwitching(), protocol.Constructed.WithNonEmptyValue(func(_ bool) (shutdown func()) { return c.deriveLatestSeenSlot(protocol) @@ -92,7 +92,7 @@ func (c *Chains) initLogger(logger log.Logger, shutdownLogger func()) (shutdown } // initChainSwitching initializes the chain switching logic. -func (c *Chains) initChainSwitching(chainSwitchingThreshold iotago.SlotIndex) (shutdown func()) { +func (c *Chains) initChainSwitching() (shutdown func()) { mainChain := c.newChain() mainChain.StartEngine.Set(true) @@ -102,6 +102,7 @@ func (c *Chains) initChainSwitching(chainSwitchingThreshold iotago.SlotIndex) (s forkingPointBelowChainSwitchingThreshold := func(chain *Chain) func(_ *Commitment, latestCommitment *Commitment) bool { return func(_ *Commitment, latestCommitment *Commitment) bool { forkingPoint := chain.ForkingPoint.Get() + chainSwitchingThreshold := iotago.SlotIndex(c.protocol.APIForSlot(latestCommitment.Slot()).ProtocolParameters().ChainSwitchingThreshold()) return forkingPoint != nil && latestCommitment != nil && (latestCommitment.ID().Slot()-forkingPoint.ID().Slot()) > chainSwitchingThreshold } diff --git a/pkg/protocol/options.go b/pkg/protocol/options.go index ac9605bf8..c3b260923 100644 --- a/pkg/protocol/options.go +++ b/pkg/protocol/options.go @@ -51,10 +51,6 @@ type Options struct { // SnapshotPath is the path to the snapshot file that should be used to initialize the protocol. SnapshotPath string - // ChainSwitchingThreshold is the threshold that defines how far away a heavier chain needs to be from its forking - // point to be considered for switching. - ChainSwitchingThreshold iotago.SlotIndex - // EngineOptions contains the options for the Engines. EngineOptions []options.Option[engine.Engine] @@ -120,8 +116,7 @@ type Options struct { // NewDefaultOptions creates new default options instance for the Protocol. func NewDefaultOptions() *Options { return &Options{ - BaseDirectory: "", - ChainSwitchingThreshold: 3, + BaseDirectory: "", PreSolidFilterProvider: presolidblockfilter.NewProvider(), PostSolidFilterProvider: postsolidblockfilter.NewProvider(), @@ -157,13 +152,6 @@ func WithSnapshotPath(snapshot string) options.Option[Protocol] { } } -// WithChainSwitchingThreshold is an option for the Protocol that allows to set the chain switching threshold. -func WithChainSwitchingThreshold(threshold iotago.SlotIndex) options.Option[Protocol] { - return func(p *Protocol) { - p.Options.ChainSwitchingThreshold = threshold - } -} - // WithPreSolidFilterProvider is an option for the Protocol that allows to set the PreSolidFilterProvider. func WithPreSolidFilterProvider(optsFilterProvider module.Provider[*engine.Engine, presolidfilter.PreSolidFilter]) options.Option[Protocol] { return func(p *Protocol) {