Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Fix startup error of missing dependency on Stratis.BitcoinD #319

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,7 +43,7 @@ public void Stop()
throw new NotImplementedException();
}

public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Builder.Feature;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void Stop()
throw new NotImplementedException();
}

public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -29,8 +30,7 @@ public void Stop()
throw new NotImplementedException();
}

/// <inheritdoc />
public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand All @@ -53,8 +53,7 @@ public void Stop()
throw new NotImplementedException();
}

/// <inheritdoc />
public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private FullNodeFeatureExecutor MissingFeatureExecutor
get
{
Mock<IFullNodeFeature> feature = new Mock<IFullNodeFeature>();
feature.Setup(f => f.ValidateDependencies(It.IsAny<IEnumerable<IFullNodeFeature>>()))
feature.Setup(f => f.ValidateDependencies(It.IsAny<IFullNodeServiceProvider>()))
.Throws(new MissingDependencyException());

var fullNodeServiceProvider = new Mock<IFullNodeServiceProvider>();
Expand Down
6 changes: 2 additions & 4 deletions Stratis.Bitcoin.Tests/Builder/FullNodeServiceProviderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public void Stop()
throw new NotImplementedException();
}

/// <inheritdoc />
public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand All @@ -89,8 +88,7 @@ public void Stop()
throw new NotImplementedException();
}

/// <inheritdoc />
public void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public void ValidateDependencies(IFullNodeServiceProvider services)
{
throw new NotImplementedException();
}
Expand Down
12 changes: 5 additions & 7 deletions Stratis.Bitcoin/Builder/Feature/FullNodeFeature.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

namespace Stratis.Bitcoin.Builder.Feature
namespace Stratis.Bitcoin.Builder.Feature
{
/// <summary>
/// Defines methods for features that are managed by the FullNode.
Expand All @@ -19,11 +17,11 @@ public interface IFullNodeFeature
void Stop();

/// <summary>
/// Validates the feature's dependencies are all present in feature collection.
/// Validates the feature's required dependencies are all present.
/// </summary>
/// <exception cref="MissingDependencyException">should be thrown if dependency is missing</exception>
/// <param name="features">feature collection from builder</param>
void ValidateDependencies(IEnumerable<IFullNodeFeature> features);
/// <param name="services">Services and features registered to node.</param>
void ValidateDependencies(IFullNodeServiceProvider services);
}

/// <summary>
Expand All @@ -47,7 +45,7 @@ public virtual void Stop()
}

/// <inheritdoc />
public virtual void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
public virtual void ValidateDependencies(IFullNodeServiceProvider services)
{
}
}
Expand Down
3 changes: 1 addition & 2 deletions Stratis.Bitcoin/Builder/FullNodeFeatureExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Stratis.Bitcoin.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Stratis.Bitcoin.Builder
{
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions Stratis.Bitcoin/Features/Miner/MiningFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -19,9 +18,12 @@ public override void Stop()
}

///<inheritdoc />
public override void ValidateDependencies(IEnumerable<IFullNodeFeature> features)
{
features.EnsureFeature<WalletFeature>();
public override void ValidateDependencies(IFullNodeServiceProvider services)
{
if (services.ServiceProvider.GetService<PosMinting>() != null)
{
services.Features.EnsureFeature<WalletFeature>();
}
}
}

Expand Down