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;
......@@ -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.
......
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