Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
a425df19
Commit
a425df19
authored
Apr 21, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Plain Diff
Added getting transactions from the Mempool.
parents
fe62fc98
1d842329
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
16 deletions
+87
-16
Program.cs
Breeze/src/Breeze.Deamon/Program.cs
+3
-2
TransactionObserver.cs
...ze/src/Breeze.Wallet/Notifications/TransactionObserver.cs
+28
-0
TransactionSubscriber.cs
.../src/Breeze.Wallet/Notifications/TransactionSubscriber.cs
+30
-0
WalletFeature.cs
Breeze/src/Breeze.Wallet/WalletFeature.cs
+2
-0
ITrackerWrapper.cs
Breeze/src/Breeze.Wallet/Wrappers/ITrackerWrapper.cs
+3
-1
TrackerWrapper.cs
Breeze/src/Breeze.Wallet/Wrappers/TrackerWrapper.cs
+21
-13
No files found.
Breeze/src/Breeze.Deamon/Program.cs
View file @
a425df19
...
...
@@ -18,11 +18,12 @@ namespace Breeze.Deamon
// configure Full Node
Logs
.
Configure
(
new
LoggerFactory
().
AddConsole
(
LogLevel
.
Trace
,
false
));
NodeSettings
nodeSettings
=
NodeSettings
.
FromArguments
(
args
);
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseWallet
()
.
UseBlockNotification
()
.
UseTransactionNotification
()
.
UseApi
()
.
Build
();
...
...
Breeze/src/Breeze.Wallet/Notifications/TransactionObserver.cs
0 → 100644
View file @
a425df19
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
);
}
}
}
Breeze/src/Breeze.Wallet/Notifications/TransactionSubscriber.cs
0 → 100644
View file @
a425df19
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
);
}
}
}
Breeze/src/Breeze.Wallet/WalletFeature.cs
View file @
a425df19
...
...
@@ -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
();
}
}
...
...
Breeze/src/Breeze.Wallet/Wrappers/ITrackerWrapper.cs
View file @
a425df19
...
...
@@ -6,6 +6,8 @@ namespace Breeze.Wallet.Wrappers
{
void
NotifyAboutBlock
(
int
height
,
Block
block
);
uint256
GetLastProcessedBlock
();
void
NotifyAboutTransaction
(
Transaction
transaction
);
uint256
GetLastProcessedBlock
();
}
}
Breeze/src/Breeze.Wallet/Wrappers/TrackerWrapper.cs
View file @
a425df19
...
...
@@ -5,27 +5,35 @@ namespace Breeze.Wallet.Wrappers
{
public
class
TrackerWrapper
:
ITrackerWrapper
{
// private readonly Tracker tracker;
// private readonly Tracker tracker;
public
TrackerWrapper
(
Network
network
)
{
//this.tracker = new Tracker(network);
}
/// <summary>
/// Get the hash of the last block that has been succesfully processed.
/// </summary>
/// <returns>The hash of the block</returns>
public
uint256
GetLastProcessedBlock
()
{
// TODO use Tracker.BestHeight. Genesis hash for now.
return
uint256
.
Parse
(
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
);
}
/// <summary>
/// Get the hash of the last block that has been succesfully processed.
/// </summary>
/// <returns>The hash of the block</returns>
public
uint256
GetLastProcessedBlock
()
{
// TODO use Tracker.BestHeight. Genesis hash for now.
return
uint256
.
Parse
(
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
);
}
public
void
NotifyAboutBlock
(
int
height
,
Block
block
)
{
// this.tracker.AddOrReplaceBlock(new Height(height), block);
Console
.
WriteLine
(
$"block notification: height:
{
height
}
, block hash:
{
block
.
Header
.
GetHash
()}
"
);
}
public
void
NotifyAboutBlock
(
int
height
,
Block
block
)
public
void
NotifyAboutTransaction
(
Transaction
transaction
)
{
//this.tracker.AddOrReplaceBlock(new Height(height), block);
Console
.
WriteLine
(
$"height:
{
height
}
, block hash:
{
block
.
Header
.
GetHash
()}
"
);
// 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
()}
"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment