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
756978c1
Commit
756978c1
authored
Jun 30, 2017
by
Dan Gershony
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Segwit check wait for chain header to download
parent
9a583b2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
LightWalletFeature.cs
Breeze/src/Breeze.Wallet/LightWalletFeature.cs
+37
-5
No files found.
Breeze/src/Breeze.Wallet/LightWalletFeature.cs
View file @
756978c1
using
Stratis.Bitcoin.Builder.Feature
;
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Stratis.Bitcoin.Builder.Feature
;
using
Microsoft.Extensions.DependencyInjection
;
using
NBitcoin
;
using
NBitcoin.Protocol
;
using
Stratis.Bitcoin
;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Connection
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Consensus.Deployments
;
using
Stratis.Bitcoin.Utilities
;
using
Stratis.Bitcoin.Wallet
;
using
Stratis.Bitcoin.Wallet.Controllers
;
...
...
@@ -18,15 +23,19 @@ namespace Breeze.Wallet
private
readonly
IConnectionManager
connectionManager
;
private
readonly
ConcurrentChain
chain
;
private
readonly
NodeDeployments
nodeDeployments
;
private
readonly
IAsyncLoopFactory
asyncLoopFactory
;
private
readonly
FullNode
.
CancellationProvider
cancellationProvider
;
public
LightWalletFeature
(
IWalletSyncManager
walletSyncManager
,
IWalletManager
walletManager
,
IConnectionManager
connectionManager
,
ConcurrentChain
chain
,
NodeDeployments
nodeDeployments
)
ConcurrentChain
chain
,
NodeDeployments
nodeDeployments
,
IAsyncLoopFactory
asyncLoopFactory
,
FullNode
.
CancellationProvider
cancellationProvider
)
{
this
.
walletSyncManager
=
walletSyncManager
;
this
.
walletManager
=
walletManager
;
this
.
connectionManager
=
connectionManager
;
this
.
chain
=
chain
;
this
.
nodeDeployments
=
nodeDeployments
;
this
.
asyncLoopFactory
=
asyncLoopFactory
;
this
.
cancellationProvider
=
cancellationProvider
;
}
public
override
void
Start
()
...
...
@@ -36,9 +45,32 @@ namespace Breeze.Wallet
this
.
walletManager
.
Initialize
();
this
.
walletSyncManager
.
Initialize
();
var
flags
=
this
.
nodeDeployments
.
GetFlags
(
this
.
walletSyncManager
.
WalletTip
);
if
(
flags
.
ScriptFlags
.
HasFlag
(
ScriptVerify
.
Witness
))
this
.
connectionManager
.
AddDiscoveredNodesRequirement
(
NodeServices
.
NODE_WITNESS
);
this
.
StartDeploymentsChecksLoop
();
}
public
void
StartDeploymentsChecksLoop
()
{
var
loopToken
=
CancellationTokenSource
.
CreateLinkedTokenSource
(
this
.
cancellationProvider
.
Cancellation
.
Token
);
this
.
asyncLoopFactory
.
Run
(
"LightWalletFeature.CheckDeployments"
,
token
=>
{
if
(!
this
.
chain
.
IsDownloaded
())
return
Task
.
CompletedTask
;
// check segwit activation on the chain of headers
// if segwit is active signal to only connect to
// nodes that also signal they are segwit nodes
var
flags
=
this
.
nodeDeployments
.
GetFlags
(
this
.
walletSyncManager
.
WalletTip
);
if
(
flags
.
ScriptFlags
.
HasFlag
(
ScriptVerify
.
Witness
))
this
.
connectionManager
.
AddDiscoveredNodesRequirement
(
NodeServices
.
NODE_WITNESS
);
// done checking
loopToken
.
Cancel
();
return
Task
.
CompletedTask
;
},
loopToken
.
Token
,
repeatEvery
:
TimeSpans
.
TenSeconds
,
startAfter
:
TimeSpans
.
TenSeconds
);
}
public
override
void
Stop
()
...
...
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