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
1d842329
Commit
1d842329
authored
8 years ago
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added syncing of the transactions with the wallet.
Final commit waiting on a new nuget package for the full node.
parent
79f14616
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
6 deletions
+77
-6
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
+11
-3
No files found.
Breeze/src/Breeze.Deamon/Program.cs
View file @
1d842329
...
@@ -18,11 +18,12 @@ namespace Breeze.Deamon
...
@@ -18,11 +18,12 @@ namespace Breeze.Deamon
// configure Full Node
// configure Full Node
Logs
.
Configure
(
new
LoggerFactory
().
AddConsole
(
LogLevel
.
Trace
,
false
));
Logs
.
Configure
(
new
LoggerFactory
().
AddConsole
(
LogLevel
.
Trace
,
false
));
NodeSettings
nodeSettings
=
NodeSettings
.
FromArguments
(
args
);
NodeSettings
nodeSettings
=
NodeSettings
.
FromArguments
(
args
);
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseNodeSettings
(
nodeSettings
)
.
UseWallet
()
.
UseWallet
()
.
UseBlockNotification
()
.
UseBlockNotification
()
.
UseTransactionNotification
()
.
UseApi
()
.
UseApi
()
.
Build
();
.
Build
();
...
...
This diff is collapsed.
Click to expand it.
Breeze/src/Breeze.Wallet/Notifications/TransactionObserver.cs
0 → 100644
View file @
1d842329
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
);
}
}
}
This diff is collapsed.
Click to expand it.
Breeze/src/Breeze.Wallet/Notifications/TransactionSubscriber.cs
0 → 100644
View file @
1d842329
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
);
}
}
}
This diff is collapsed.
Click to expand it.
Breeze/src/Breeze.Wallet/WalletFeature.cs
View file @
1d842329
...
@@ -26,6 +26,8 @@ namespace Breeze.Wallet
...
@@ -26,6 +26,8 @@ namespace Breeze.Wallet
{
{
BlockSubscriber
sub
=
new
BlockSubscriber
(
signals
.
Blocks
,
new
BlockObserver
(
chain
,
trackerWrapper
));
BlockSubscriber
sub
=
new
BlockSubscriber
(
signals
.
Blocks
,
new
BlockObserver
(
chain
,
trackerWrapper
));
sub
.
Subscribe
();
sub
.
Subscribe
();
TransactionSubscriber
txSub
=
new
TransactionSubscriber
(
signals
.
Transactions
,
new
TransactionObserver
(
trackerWrapper
));
txSub
.
Subscribe
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Breeze/src/Breeze.Wallet/Wrappers/ITrackerWrapper.cs
View file @
1d842329
...
@@ -6,6 +6,8 @@ namespace Breeze.Wallet.Wrappers
...
@@ -6,6 +6,8 @@ namespace Breeze.Wallet.Wrappers
{
{
void
NotifyAboutBlock
(
int
height
,
Block
block
);
void
NotifyAboutBlock
(
int
height
,
Block
block
);
uint256
GetLastProcessedBlock
();
void
NotifyAboutTransaction
(
Transaction
transaction
);
uint256
GetLastProcessedBlock
();
}
}
}
}
This diff is collapsed.
Click to expand it.
Breeze/src/Breeze.Wallet/Wrappers/TrackerWrapper.cs
View file @
1d842329
...
@@ -13,8 +13,8 @@ namespace Breeze.Wallet.Wrappers
...
@@ -13,8 +13,8 @@ namespace Breeze.Wallet.Wrappers
{
{
this
.
tracker
=
new
Tracker
(
network
);
this
.
tracker
=
new
Tracker
(
network
);
}
}
/// <summary>
/// <summary>
/// Get the hash of the last block that has been succesfully processed.
/// Get the hash of the last block that has been succesfully processed.
/// </summary>
/// </summary>
/// <returns>The hash of the block</returns>
/// <returns>The hash of the block</returns>
...
@@ -27,7 +27,15 @@ namespace Breeze.Wallet.Wrappers
...
@@ -27,7 +27,15 @@ namespace Breeze.Wallet.Wrappers
public
void
NotifyAboutBlock
(
int
height
,
Block
block
)
public
void
NotifyAboutBlock
(
int
height
,
Block
block
)
{
{
this
.
tracker
.
AddOrReplaceBlock
(
new
Height
(
height
),
block
);
this
.
tracker
.
AddOrReplaceBlock
(
new
Height
(
height
),
block
);
Console
.
WriteLine
(
$"height:
{
height
}
, block hash:
{
block
.
Header
.
GetHash
()}
"
);
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
()}
"
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
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