diff --git a/Stratis.Bitcoin.Tests/Builder/Feature/FeatureCollectionTest.cs b/Stratis.Bitcoin.Tests/Builder/Feature/FeatureCollectionTest.cs index 5a04cddb8a2..f288b87f745 100644 --- a/Stratis.Bitcoin.Tests/Builder/Feature/FeatureCollectionTest.cs +++ b/Stratis.Bitcoin.Tests/Builder/Feature/FeatureCollectionTest.cs @@ -1,6 +1,6 @@ -using Stratis.Bitcoin.Builder.Feature; +using Stratis.Bitcoin.Builder; +using Stratis.Bitcoin.Builder.Feature; using System; -using System.Collections.Generic; using Xunit; namespace Stratis.Bitcoin.Tests.Builder.Feature @@ -43,7 +43,7 @@ public void Stop() throw new NotImplementedException(); } - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } diff --git a/Stratis.Bitcoin.Tests/Builder/Feature/FeatureRegistrationTest.cs b/Stratis.Bitcoin.Tests/Builder/Feature/FeatureRegistrationTest.cs index 20c3695cded..4cff8ab8808 100644 --- a/Stratis.Bitcoin.Tests/Builder/Feature/FeatureRegistrationTest.cs +++ b/Stratis.Bitcoin.Tests/Builder/Feature/FeatureRegistrationTest.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Stratis.Bitcoin.Builder; using Stratis.Bitcoin.Builder.Feature; using System; using System.Collections.Generic; @@ -113,7 +114,7 @@ public void Stop() throw new NotImplementedException(); } - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } diff --git a/Stratis.Bitcoin.Tests/Builder/Feature/FeaturesExtensionsTest.cs b/Stratis.Bitcoin.Tests/Builder/Feature/FeaturesExtensionsTest.cs index e70c7456759..dd15a41a6c5 100644 --- a/Stratis.Bitcoin.Tests/Builder/Feature/FeaturesExtensionsTest.cs +++ b/Stratis.Bitcoin.Tests/Builder/Feature/FeaturesExtensionsTest.cs @@ -1,4 +1,5 @@ -using Stratis.Bitcoin.Builder.Feature; +using Stratis.Bitcoin.Builder; +using Stratis.Bitcoin.Builder.Feature; using System; using System.Collections.Generic; using Xunit; @@ -29,8 +30,7 @@ public void Stop() throw new NotImplementedException(); } - /// - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } @@ -53,8 +53,7 @@ public void Stop() throw new NotImplementedException(); } - /// - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } diff --git a/Stratis.Bitcoin.Tests/Builder/FullNodeFeatureExecutorTest.cs b/Stratis.Bitcoin.Tests/Builder/FullNodeFeatureExecutorTest.cs index a6aed3c1f18..b94cca2525a 100644 --- a/Stratis.Bitcoin.Tests/Builder/FullNodeFeatureExecutorTest.cs +++ b/Stratis.Bitcoin.Tests/Builder/FullNodeFeatureExecutorTest.cs @@ -25,7 +25,7 @@ private FullNodeFeatureExecutor MissingFeatureExecutor get { Mock feature = new Mock(); - feature.Setup(f => f.ValidateDependencies(It.IsAny>())) + feature.Setup(f => f.ValidateDependencies(It.IsAny())) .Throws(new MissingDependencyException()); var fullNodeServiceProvider = new Mock(); diff --git a/Stratis.Bitcoin.Tests/Builder/FullNodeServiceProviderTest.cs b/Stratis.Bitcoin.Tests/Builder/FullNodeServiceProviderTest.cs index 768cf96c7bd..ba923616c50 100644 --- a/Stratis.Bitcoin.Tests/Builder/FullNodeServiceProviderTest.cs +++ b/Stratis.Bitcoin.Tests/Builder/FullNodeServiceProviderTest.cs @@ -68,8 +68,7 @@ public void Stop() throw new NotImplementedException(); } - /// - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } @@ -89,8 +88,7 @@ public void Stop() throw new NotImplementedException(); } - /// - public void ValidateDependencies(IEnumerable features) + public void ValidateDependencies(IFullNodeServiceProvider services) { throw new NotImplementedException(); } diff --git a/Stratis.Bitcoin/Builder/Feature/FullNodeFeature.cs b/Stratis.Bitcoin/Builder/Feature/FullNodeFeature.cs index 52cf327b55a..6d504a78f76 100644 --- a/Stratis.Bitcoin/Builder/Feature/FullNodeFeature.cs +++ b/Stratis.Bitcoin/Builder/Feature/FullNodeFeature.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Stratis.Bitcoin.Builder.Feature +namespace Stratis.Bitcoin.Builder.Feature { /// /// Defines methods for features that are managed by the FullNode. @@ -19,11 +17,11 @@ public interface IFullNodeFeature void Stop(); /// - /// Validates the feature's dependencies are all present in feature collection. + /// Validates the feature's required dependencies are all present. /// /// should be thrown if dependency is missing - /// feature collection from builder - void ValidateDependencies(IEnumerable features); + /// Services and features registered to node. + void ValidateDependencies(IFullNodeServiceProvider services); } /// @@ -47,7 +45,7 @@ public virtual void Stop() } /// - public virtual void ValidateDependencies(IEnumerable features) + public virtual void ValidateDependencies(IFullNodeServiceProvider services) { } } diff --git a/Stratis.Bitcoin/Builder/FullNodeFeatureExecutor.cs b/Stratis.Bitcoin/Builder/FullNodeFeatureExecutor.cs index 52718174503..2111128ee51 100644 --- a/Stratis.Bitcoin/Builder/FullNodeFeatureExecutor.cs +++ b/Stratis.Bitcoin/Builder/FullNodeFeatureExecutor.cs @@ -3,7 +3,6 @@ using Stratis.Bitcoin.Utilities; using System; using System.Collections.Generic; -using System.Linq; namespace Stratis.Bitcoin.Builder { @@ -53,7 +52,7 @@ public void Start() { try { - this.Execute(service => service.ValidateDependencies(this.node.Services.Features.ToList())); + this.Execute(service => service.ValidateDependencies(this.node.Services)); this.Execute(service => service.Start()); } catch (Exception ex) diff --git a/Stratis.Bitcoin/Features/Miner/MiningFeature.cs b/Stratis.Bitcoin/Features/Miner/MiningFeature.cs index 094004257e6..049d79e1523 100644 --- a/Stratis.Bitcoin/Features/Miner/MiningFeature.cs +++ b/Stratis.Bitcoin/Features/Miner/MiningFeature.cs @@ -2,7 +2,6 @@ using Stratis.Bitcoin.Builder; using Stratis.Bitcoin.Builder.Feature; using Stratis.Bitcoin.Features.Wallet; -using System.Collections.Generic; namespace Stratis.Bitcoin.Features.Miner { @@ -19,9 +18,12 @@ public override void Stop() } /// - public override void ValidateDependencies(IEnumerable features) - { - features.EnsureFeature(); + public override void ValidateDependencies(IFullNodeServiceProvider services) + { + if (services.ServiceProvider.GetService() != null) + { + services.Features.EnsureFeature(); + } } }