Commit 114342e1 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Added the method calling HBitcoin's tracker to track blocks.

parent 72c7a83c
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
......@@ -20,8 +15,8 @@ namespace Breeze.Api
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
......@@ -36,6 +31,9 @@ namespace Breeze.Api
// add DI classes for controllers.
services.AddTransient<ISafeWrapper, SafeWrapper>();
services.AddTransient<ITrackerWrapper, TrackerWrapper>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......@@ -44,7 +42,7 @@ namespace Breeze.Api
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
}
app.UseMvc();
}
}
}
using NBitcoin;
namespace Breeze.Api.Wrappers
{
public interface ITrackerWrapper
{
void NotifyAboutBlock(int height, Block block);
}
}
using NBitcoin;
using HBitcoin.FullBlockSpv;
using HBitcoin.Models;
namespace Breeze.Api.Wrappers
{
public class TrackerWrapper : ITrackerWrapper
{
private readonly Tracker tracker;
public TrackerWrapper(Network network)
{
this.tracker = new Tracker(network);
}
public void NotifyAboutBlock(int height, Block block)
{
this.tracker.AddOrReplaceBlock(new Height(height), block);
}
}
}
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