Commit a425df19 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Added getting transactions from the Mempool.

parents fe62fc98 1d842329
......@@ -23,6 +23,7 @@ namespace Breeze.Deamon
.UseNodeSettings(nodeSettings)
.UseWallet()
.UseBlockNotification()
.UseTransactionNotification()
.UseApi()
.Build();
......
using NBitcoin;
using Stratis.Bitcoin;
using Breeze.Wallet.Wrappers;
namespace Breeze.Wallet.Notifications
{
/// <summary>
/// Observer that receives notifications about the arrival of new <see cref="Transaction"/>s.
/// </summary>
public class TransactionObserver : SignalObserver<Transaction>
{
private readonly ITrackerWrapper trackerWrapper;
public TransactionObserver(ITrackerWrapper trackerWrapper)
{
this.trackerWrapper = trackerWrapper;
}
/// <summary>
/// Manages what happens when a new transaction is received.
/// </summary>
/// <param name="transaction">The new transaction</param>
protected override void OnNextCore(Transaction transaction)
{
this.trackerWrapper.NotifyAboutTransaction(transaction);
}
}
}
using Stratis.Bitcoin;
using System;
using NBitcoin;
namespace Breeze.Wallet.Notifications
{
/// <summary>
/// Manages the subscription of the transaction observer to the transaction signaler.
/// </summary>
public class TransactionSubscriber
{
private readonly ISignaler<Transaction> signaler;
private readonly TransactionObserver observer;
public TransactionSubscriber(ISignaler<Transaction> signaler, TransactionObserver observer)
{
this.signaler = signaler;
this.observer = observer;
}
/// <summary>
/// Subscribes the transaction observer to the transaction signaler.
/// </summary>
/// <returns>An <see cref="IDisposable"/></returns>
public IDisposable Subscribe()
{
return this.signaler.Subscribe(this.observer);
}
}
}
......@@ -26,6 +26,8 @@ namespace Breeze.Wallet
{
BlockSubscriber sub = new BlockSubscriber(signals.Blocks, new BlockObserver(chain, trackerWrapper));
sub.Subscribe();
TransactionSubscriber txSub = new TransactionSubscriber(signals.Transactions, new TransactionObserver(trackerWrapper));
txSub.Subscribe();
}
}
......
......@@ -6,6 +6,8 @@ namespace Breeze.Wallet.Wrappers
{
void NotifyAboutBlock(int height, Block block);
void NotifyAboutTransaction(Transaction transaction);
uint256 GetLastProcessedBlock();
}
}
......@@ -24,8 +24,16 @@ namespace Breeze.Wallet.Wrappers
public void NotifyAboutBlock(int height, Block block)
{
//this.tracker.AddOrReplaceBlock(new Height(height), block);
Console.WriteLine($"height: {height}, block hash: {block.Header.GetHash()}");
// this.tracker.AddOrReplaceBlock(new Height(height), block);
Console.WriteLine($"block notification: height: {height}, block hash: {block.Header.GetHash()}");
}
public void NotifyAboutTransaction(Transaction transaction)
{
// TODO what should the height be? is it necessary?
// this.tracker.ProcessTransaction(new SmartTransaction(transaction, new Height(0)));
Console.WriteLine($"transaction notification: tx hash {transaction.GetHash()}");
}
}
}
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