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
f0f0c4c4
Commit
f0f0c4c4
authored
Jun 30, 2017
by
Jeremy Bokobza
Committed by
GitHub
Jun 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #127 from dangershony/segwit-wait-chain
Segwit check, wait for chain header to download
parents
e5b5e7d2
756978c1
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 @
f0f0c4c4
using
Stratis.Bitcoin.Builder.Feature
;
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Stratis.Bitcoin.Builder.Feature
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
NBitcoin
;
using
NBitcoin
;
using
NBitcoin.Protocol
;
using
NBitcoin.Protocol
;
using
Stratis.Bitcoin
;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Connection
;
using
Stratis.Bitcoin.Connection
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Consensus.Deployments
;
using
Stratis.Bitcoin.Consensus.Deployments
;
using
Stratis.Bitcoin.Utilities
;
using
Stratis.Bitcoin.Wallet
;
using
Stratis.Bitcoin.Wallet
;
using
Stratis.Bitcoin.Wallet.Controllers
;
using
Stratis.Bitcoin.Wallet.Controllers
;
...
@@ -18,15 +23,19 @@ namespace Breeze.Wallet
...
@@ -18,15 +23,19 @@ namespace Breeze.Wallet
private
readonly
IConnectionManager
connectionManager
;
private
readonly
IConnectionManager
connectionManager
;
private
readonly
ConcurrentChain
chain
;
private
readonly
ConcurrentChain
chain
;
private
readonly
NodeDeployments
nodeDeployments
;
private
readonly
NodeDeployments
nodeDeployments
;
private
readonly
IAsyncLoopFactory
asyncLoopFactory
;
private
readonly
FullNode
.
CancellationProvider
cancellationProvider
;
public
LightWalletFeature
(
IWalletSyncManager
walletSyncManager
,
IWalletManager
walletManager
,
IConnectionManager
connectionManager
,
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
.
walletSyncManager
=
walletSyncManager
;
this
.
walletManager
=
walletManager
;
this
.
walletManager
=
walletManager
;
this
.
connectionManager
=
connectionManager
;
this
.
connectionManager
=
connectionManager
;
this
.
chain
=
chain
;
this
.
chain
=
chain
;
this
.
nodeDeployments
=
nodeDeployments
;
this
.
nodeDeployments
=
nodeDeployments
;
this
.
asyncLoopFactory
=
asyncLoopFactory
;
this
.
cancellationProvider
=
cancellationProvider
;
}
}
public
override
void
Start
()
public
override
void
Start
()
...
@@ -36,9 +45,32 @@ namespace Breeze.Wallet
...
@@ -36,9 +45,32 @@ namespace Breeze.Wallet
this
.
walletManager
.
Initialize
();
this
.
walletManager
.
Initialize
();
this
.
walletSyncManager
.
Initialize
();
this
.
walletSyncManager
.
Initialize
();
var
flags
=
this
.
nodeDeployments
.
GetFlags
(
this
.
walletSyncManager
.
WalletTip
);
this
.
StartDeploymentsChecksLoop
();
if
(
flags
.
ScriptFlags
.
HasFlag
(
ScriptVerify
.
Witness
))
}
this
.
connectionManager
.
AddDiscoveredNodesRequirement
(
NodeServices
.
NODE_WITNESS
);
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
()
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