Commit 344af23c authored by Jeremy Bokobza's avatar Jeremy Bokobza Committed by GitHub

Merge pull request #179 from bokobza/master

Removed TumbleBit from Breeze as it will be used as an add on
parents c3923f5e 07459133

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{807563C4-7259-434D-B604-A14C3DCF8E30}"
EndProject
......@@ -20,12 +20,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.Api.Tests", "src\Bre
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.Wallet", "src\Breeze.Wallet\Breeze.Wallet.csproj", "{D16CD478-9D1E-4C69-91AD-43539E94A215}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.TumbleBit.Client", "src\Breeze.TumbleBit.Client\Breeze.TumbleBit.Client.csproj", "{2490DD1A-6C14-47F2-A9C6-56761A52E2D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TumbleBit", "TumbleBit", "{1B724678-2B73-483E-B981-3A6733C2194E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NTumbleBit", "src\NTumbleBit\NTumbleBit.csproj", "{29E411B1-5687-43EE-A71B-6CCEC2289129}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.Daemon", "src\Breeze.Daemon\Breeze.Daemon.csproj", "{AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin", "..\StratisBitcoinFullNode\Stratis.Bitcoin\Stratis.Bitcoin.csproj", "{C93CB29F-C0A1-40D6-A4CC-B93C75423ED5}"
......@@ -54,14 +48,6 @@ Global
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Release|Any CPU.Build.0 = Release|Any CPU
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9}.Release|Any CPU.Build.0 = Release|Any CPU
{29E411B1-5687-43EE-A71B-6CCEC2289129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29E411B1-5687-43EE-A71B-6CCEC2289129}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29E411B1-5687-43EE-A71B-6CCEC2289129}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29E411B1-5687-43EE-A71B-6CCEC2289129}.Release|Any CPU.Build.0 = Release|Any CPU
{AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
......@@ -90,8 +76,6 @@ Global
{E7B3E9EB-34E8-4B10-B296-4D5270E314A4} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{BD5174B4-DCE8-4594-9A16-B83E56767770} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{D16CD478-9D1E-4C69-91AD-43539E94A215} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{29E411B1-5687-43EE-A71B-6CCEC2289129} = {1B724678-2B73-483E-B981-3A6733C2194E}
{AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D} = {807563C4-7259-434D-B604-A14C3DCF8E30}
EndGlobalSection
EndGlobal
......@@ -6,43 +6,42 @@ using Microsoft.Extensions.Logging;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Builder.Feature;
using Stratis.Bitcoin.Logging;
using Stratis.Bitcoin.Utilities;
namespace Breeze.Api
{
/// <summary>
/// Provides an Api to the full node
/// </summary>
public class ApiFeature : FullNodeFeature
{
private readonly IFullNodeBuilder fullNodeBuilder;
private readonly FullNode fullNode;
private readonly ApiFeatureOptions apiFeatureOptions;
private readonly IAsyncLoopFactory asyncLoopFactory;
private readonly ILogger logger;
/// <summary>
/// Provides an Api to the full node
/// </summary>
public class ApiFeature : FullNodeFeature
{
private readonly IFullNodeBuilder fullNodeBuilder;
private readonly FullNode fullNode;
private readonly ApiFeatureOptions apiFeatureOptions;
private readonly IAsyncLoopFactory asyncLoopFactory;
private readonly ILogger logger;
public ApiFeature(
IFullNodeBuilder fullNodeBuilder,
FullNode fullNode,
ApiFeatureOptions apiFeatureOptions,
IAsyncLoopFactory asyncLoopFactory,
ILoggerFactory loggerFactory)
{
this.fullNodeBuilder = fullNodeBuilder;
this.fullNode = fullNode;
this.apiFeatureOptions = apiFeatureOptions;
this.asyncLoopFactory = asyncLoopFactory;
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
}
public ApiFeature(
IFullNodeBuilder fullNodeBuilder,
FullNode fullNode,
ApiFeatureOptions apiFeatureOptions,
IAsyncLoopFactory asyncLoopFactory,
ILoggerFactory loggerFactory)
{
this.fullNodeBuilder = fullNodeBuilder;
this.fullNode = fullNode;
this.apiFeatureOptions = apiFeatureOptions;
this.asyncLoopFactory = asyncLoopFactory;
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
}
public override void Start()
{
this.logger.LogInformation($"Api starting on url {this.fullNode.Settings.ApiUri}");
public override void Start()
{
this.logger.LogInformation($"Api starting on url {this.fullNode.Settings.ApiUri}");
Program.Initialize(this.fullNodeBuilder.Services, this.fullNode);
this.TryStartKeepaliveMonitor();
}
this.TryStartKeepaliveMonitor();
}
/// <summary>
/// A KeepaliveMonitor when enabled will shutdown the
......@@ -50,26 +49,26 @@ namespace Breeze.Api
/// during a certain trashold window
/// </summary>
public void TryStartKeepaliveMonitor()
{
if (this.apiFeatureOptions.KeepaliveMonitor?.KeepaliveInterval.TotalSeconds > 0)
{
this.asyncLoopFactory.Run("ApiFeature.KeepaliveMonitor", token =>
{
// shortened for redability
var monitor = this.apiFeatureOptions.KeepaliveMonitor;
{
if (this.apiFeatureOptions.KeepaliveMonitor?.KeepaliveInterval.TotalSeconds > 0)
{
this.asyncLoopFactory.Run("ApiFeature.KeepaliveMonitor", token =>
{
// shortened for redability
var monitor = this.apiFeatureOptions.KeepaliveMonitor;
// check the trashold to trigger a shutdown
if (monitor.LastBeat.Add(monitor.KeepaliveInterval) < DateTime.UtcNow)
this.fullNode.Stop();
// check the trashold to trigger a shutdown
if (monitor.LastBeat.Add(monitor.KeepaliveInterval) < DateTime.UtcNow)
this.fullNode.Stop();
return Task.CompletedTask;
},
this.fullNode.NodeLifetime.ApplicationStopping,
repeatEvery: this.apiFeatureOptions.KeepaliveMonitor?.KeepaliveInterval,
startAfter: TimeSpans.Minute);
}
}
}
return Task.CompletedTask;
},
this.fullNode.NodeLifetime.ApplicationStopping,
repeatEvery: this.apiFeatureOptions.KeepaliveMonitor?.KeepaliveInterval,
startAfter: TimeSpans.Minute);
}
}
}
public class ApiFeatureOptions
{
......@@ -82,25 +81,25 @@ namespace Breeze.Api
}
public static class ApiFeatureExtension
{
public static IFullNodeBuilder UseApi(this IFullNodeBuilder fullNodeBuilder, Action<ApiFeatureOptions> optionsAction = null)
{
{
public static IFullNodeBuilder UseApi(this IFullNodeBuilder fullNodeBuilder, Action<ApiFeatureOptions> optionsAction = null)
{
// TODO: move the options in to the feature builder
var options = new ApiFeatureOptions();
var options = new ApiFeatureOptions();
optionsAction?.Invoke(options);
fullNodeBuilder.ConfigureFeature(features =>
{
features
.AddFeature<ApiFeature>()
.FeatureServices(services =>
{
services.AddSingleton(fullNodeBuilder);
services.AddSingleton(options);
});
});
{
features
.AddFeature<ApiFeature>()
.FeatureServices(services =>
{
services.AddSingleton(fullNodeBuilder);
services.AddSingleton(options);
});
});
return fullNodeBuilder;
}
}
return fullNodeBuilder;
}
}
}
using System;
using System.ComponentModel.DataAnnotations;
using Breeze.Api.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using NBitcoin;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Notifications;
namespace Breeze.Api.Controllers
{
[Route("api/[controller]")]
public class NodeController : Controller
{
private readonly IFullNode fullNode;
private readonly ApiFeatureOptions apiFeatureOptions;
public NodeController(IFullNode fullNode, ApiFeatureOptions apiFeatureOptions)
{
this.fullNode = fullNode;
this.apiFeatureOptions = apiFeatureOptions;
}
{
[Route("api/[controller]")]
public class NodeController : Controller
{
private readonly IFullNode fullNode;
private readonly ApiFeatureOptions apiFeatureOptions;
public NodeController(IFullNode fullNode, ApiFeatureOptions apiFeatureOptions)
{
this.fullNode = fullNode;
this.apiFeatureOptions = apiFeatureOptions;
}
/// <summary>
/// Returns some general information about the status of the underlying node.
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("status")]
public IActionResult Status()
{
return this.NotFound();
}
[HttpGet]
[Route("status")]
public IActionResult Status()
{
return this.NotFound();
}
/// <summary>
/// Trigger a shoutdown of the current running node.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("shutdown")]
public IActionResult Shutdown()
{
/// <summary>
/// Trigger a shoutdown of the current running node.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("shutdown")]
public IActionResult Shutdown()
{
// start the node shutdown process
this.fullNode.Stop();
return this.Ok();
}
/// <summary>
/// Set the keepalive flag.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("keepalive")]
public IActionResult Keepalive()
{
if (this.apiFeatureOptions.KeepaliveMonitor == null)
return new ObjectResult("Keepalive Disabled") {StatusCode = 405}; // (405) Method Not Allowed
return this.Ok();
}
this.apiFeatureOptions.KeepaliveMonitor.LastBeat = DateTime.UtcNow;
return this.Ok();
}
}
/// <summary>
/// Set the keepalive flag.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("keepalive")]
public IActionResult Keepalive()
{
if (this.apiFeatureOptions.KeepaliveMonitor == null)
return new ObjectResult("Keepalive Disabled") {StatusCode = 405}; // (405) Method Not Allowed
this.apiFeatureOptions.KeepaliveMonitor.LastBeat = DateTime.UtcNow;
return this.Ok();
}
}
}
\ No newline at end of file
......@@ -7,22 +7,22 @@ namespace Breeze.Api
{
public static class MvcBuilderExtensions
{
/// <summary>
/// Finds all the types that are <see cref="Controller"/> and add them to the Api as services.
/// </summary>
/// <param name="builder">The builder</param>
/// <param name="services">The services to look into</param>
/// <returns>The Mvc builder</returns>
public static IMvcBuilder AddControllers(this IMvcBuilder builder, IServiceCollection services)
{
var controllerTypes = services.Where(s => s.ServiceType.GetTypeInfo().BaseType == typeof(Controller));
foreach (var controllerType in controllerTypes)
{
builder.AddApplicationPart(controllerType.ServiceType.GetTypeInfo().Assembly);
}
/// <summary>
/// Finds all the types that are <see cref="Controller"/> and add them to the Api as services.
/// </summary>
/// <param name="builder">The builder</param>
/// <param name="services">The services to look into</param>
/// <returns>The Mvc builder</returns>
public static IMvcBuilder AddControllers(this IMvcBuilder builder, IServiceCollection services)
{
var controllerTypes = services.Where(s => s.ServiceType.GetTypeInfo().BaseType == typeof(Controller));
foreach (var controllerType in controllerTypes)
{
builder.AddApplicationPart(controllerType.ServiceType.GetTypeInfo().Assembly);
}
builder.AddControllersAsServices();
return builder;
}
}
builder.AddControllersAsServices();
return builder;
}
}
}
......@@ -6,45 +6,45 @@ using Stratis.Bitcoin;
namespace Breeze.Api
{
public class Program
{
public static void Main(string[] args)
{
}
public class Program
{
public static void Main(string[] args)
{
}
public static void Initialize(IEnumerable<ServiceDescriptor> services, FullNode fullNode)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseUrls(fullNode.Settings.ApiUri.ToString())
.ConfigureServices(collection =>
{
if (services == null || fullNode == null)
{
return;
}
// copies all the services defined for the full node to the Api.
// also copies over singleton instances already defined
foreach (var service in services)
{
var obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType);
if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null)
{
collection.AddSingleton(service.ServiceType, obj);
}
else
{
collection.Add(service);
}
}
})
.UseStartup<Startup>()
.Build();
public static void Initialize(IEnumerable<ServiceDescriptor> services, FullNode fullNode)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseUrls(fullNode.Settings.ApiUri.ToString())
.ConfigureServices(collection =>
{
if (services == null || fullNode == null)
{
return;
}
host.Start();
}
}
// copies all the services defined for the full node to the Api.
// also copies over singleton instances already defined
foreach (var service in services)
{
var obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType);
if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null)
{
collection.AddSingleton(service.ServiceType, obj);
}
else
{
collection.Add(service);
}
}
})
.UseStartup<Startup>()
.Build();
host.Start();
}
}
}
......@@ -11,83 +11,83 @@ using Swashbuckle.AspNetCore.Swagger;
namespace Breeze.Api
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add service and create Policy to allow Cross-Origin Requests
services.AddCors
(
options =>
{
options.AddPolicy
(
"CorsPolicy",
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add service and create Policy to allow Cross-Origin Requests
services.AddCors
(
options =>
{
options.AddPolicy
(
"CorsPolicy",
builder =>
{
var allowedDomains = new[]{"http://localhost","http://localhost:4200"};
builder =>
{
var allowedDomains = new[] { "http://localhost", "http://localhost:4200" };
builder
.WithOrigins(allowedDomains)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
}
);
});
// Add framework services.
services.AddMvc(options => options.Filters.Add(typeof(LoggingActionFilter)))
// add serializers for NBitcoin objects
.AddJsonOptions(options => NBitcoin.JsonConverters.Serializer.RegisterFrontConverters(options.SerializerSettings))
.AddControllers(services);
builder
.WithOrigins(allowedDomains)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
}
);
});
// Register the Swagger generator, defining one or more Swagger documents
services.AddSwaggerGen(setup =>
{
setup.SwaggerDoc("v1", new Info { Title = "Breeze.Api", Version = "v1" });
// Add framework services.
services.AddMvc(options => options.Filters.Add(typeof(LoggingActionFilter)))
// add serializers for NBitcoin objects
.AddJsonOptions(options => NBitcoin.JsonConverters.Serializer.RegisterFrontConverters(options.SerializerSettings))
.AddControllers(services);
//Set the comments path for the swagger json and ui.
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var apiXmlPath = Path.Combine(basePath, "Breeze.Api.xml");
var walletXmlPath = Path.Combine(basePath, "Breeze.Wallet.xml");
setup.IncludeXmlComments(apiXmlPath);
setup.IncludeXmlComments(walletXmlPath);
// Register the Swagger generator, defining one or more Swagger documents
services.AddSwaggerGen(setup =>
{
setup.SwaggerDoc("v1", new Info { Title = "Breeze.Api", Version = "v1" });
//Set the comments path for the swagger json and ui.
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var apiXmlPath = Path.Combine(basePath, "Breeze.Api.xml");
var walletXmlPath = Path.Combine(basePath, "Breeze.Wallet.xml");
setup.IncludeXmlComments(apiXmlPath);
setup.IncludeXmlComments(walletXmlPath);
});
}
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseCors("CorsPolicy");
app.UseCors("CorsPolicy");
app.UseMvc();
app.UseMvc();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Breeze.Api V1");
});
}
}
// Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Breeze.Api V1");
});
}
}
}
......@@ -15,7 +15,6 @@
<ItemGroup>
<ProjectReference Include="..\..\..\StratisBitcoinFullNode\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
<ProjectReference Include="..\Breeze.Api\Breeze.Api.csproj" />
<ProjectReference Include="..\Breeze.TumbleBit.Client\Breeze.TumbleBit.Client.csproj" />
<ProjectReference Include="..\Breeze.Wallet\Breeze.Wallet.csproj" />
</ItemGroup>
......
using System;
using System.Linq;
using System.Threading;
using Breeze.Api;
using Breeze.TumbleBit;
using Microsoft.Extensions.Logging;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Configuration;
using Stratis.Bitcoin.Logging;
using Breeze.Wallet;
using NBitcoin;
using NBitcoin.Protocol;
......@@ -18,7 +13,6 @@ using Stratis.Bitcoin.Miner;
using Stratis.Bitcoin.Notifications;
using Stratis.Bitcoin.Utilities;
using Stratis.Bitcoin.Wallet;
using Stratis.Bitcoin.WatchOnlyWallet;
namespace Breeze.Daemon
{
......@@ -91,17 +85,7 @@ namespace Breeze.Daemon
.UseApi();
}
}
// TODO: Add this when TB is enabled
//// add the tumbler's settings
//var tumblerAddress = args.SingleOrDefault(arg => arg.StartsWith("-tumbler-uri="));
//if (!string.IsNullOrEmpty(tumblerAddress))
//{
// tumblerAddress = tumblerAddress.Replace("-tumbler-uri=", string.Empty);
// fullNodeBuilder.UseTumbleBit(new Uri(tumblerAddress));
// fullNodeBuilder.UseWatchOnlyWallet();
//}
var node = fullNodeBuilder.Build();
//start Full Node - this will also start the API
......
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Stratis.Bitcoin.Builder.Feature;
using Microsoft.Extensions.DependencyInjection;
......@@ -8,7 +7,6 @@ using NBitcoin.Protocol;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Connection;
using Stratis.Bitcoin.Consensus;
using Stratis.Bitcoin.Consensus.Deployments;
using Stratis.Bitcoin.Utilities;
using Stratis.Bitcoin.Wallet;
......@@ -25,9 +23,9 @@ namespace Breeze.Wallet
private readonly ConcurrentChain chain;
private readonly NodeDeployments nodeDeployments;
private readonly IAsyncLoopFactory asyncLoopFactory;
private readonly INodeLifetime nodeLifetime;
private readonly INodeLifetime nodeLifetime;
public LightWalletFeature(IWalletSyncManager walletSyncManager, IWalletManager walletManager, IConnectionManager connectionManager,
public LightWalletFeature(IWalletSyncManager walletSyncManager, IWalletManager walletManager, IConnectionManager connectionManager,
ConcurrentChain chain, NodeDeployments nodeDeployments, IAsyncLoopFactory asyncLoopFactory, INodeLifetime nodeLifetime)
{
this.walletSyncManager = walletSyncManager;
......@@ -36,7 +34,7 @@ namespace Breeze.Wallet
this.chain = chain;
this.nodeDeployments = nodeDeployments;
this.asyncLoopFactory = asyncLoopFactory;
this.nodeLifetime = nodeLifetime;
this.nodeLifetime = nodeLifetime;
}
public override void Start()
......
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NBitcoin;
using NBitcoin.JsonConverters;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Notifications;
using Stratis.Bitcoin.Utilities;
......@@ -23,20 +21,20 @@ namespace Breeze.Wallet
private readonly ILogger logger;
private readonly Signals signals;
private ChainedBlock walletTip;
private readonly INodeLifetime nodeLifetime;
private readonly IAsyncLoopFactory asyncLoopFactory;
private readonly INodeLifetime nodeLifetime;
private readonly IAsyncLoopFactory asyncLoopFactory;
public ChainedBlock WalletTip => this.walletTip;
public ChainedBlock WalletTip => this.walletTip;
public LightWalletSyncManager(
ILoggerFactory loggerFactory,
IWalletManager walletManager,
ConcurrentChain chain,
Network network,
ILoggerFactory loggerFactory,
IWalletManager walletManager,
ConcurrentChain chain,
Network network,
BlockNotification blockNotification,
Signals signals,
INodeLifetime nodeLifetime,
IAsyncLoopFactory asyncLoopFactory)
Signals signals,
INodeLifetime nodeLifetime,
IAsyncLoopFactory asyncLoopFactory)
{
this.walletManager = walletManager as WalletManager;
this.chain = chain;
......@@ -45,7 +43,7 @@ namespace Breeze.Wallet
this.coinType = (CoinType)network.Consensus.CoinType;
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
this.nodeLifetime = nodeLifetime;
this.asyncLoopFactory = asyncLoopFactory;
this.asyncLoopFactory = asyncLoopFactory;
}
/// <inheritdoc />
......@@ -183,7 +181,7 @@ namespace Breeze.Wallet
// if the chain is already past the height we want to sync from, we don't wait, even though the chain might not be fully downloaded.
if (this.chain.Tip.Height < height)
{
this.asyncLoopFactory.RunUntil("WalletFeature.DownloadChain", this.nodeLifetime.ApplicationStopping,
this.asyncLoopFactory.RunUntil("WalletFeature.DownloadChain", this.nodeLifetime.ApplicationStopping,
() => this.chain.Tip.Height >= height,
() => this.StartSync(height),
(ex) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment