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
8036646f
Commit
8036646f
authored
Jun 02, 2017
by
Dan Gershony
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Light wallet sync manager
parent
8e6ab15d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
58 deletions
+152
-58
.gitignore
.gitignore
+1
-0
Breeze.sln
Breeze/Breeze.sln
+5
-6
LoggingActionFilter.cs
Breeze/src/Breeze.Api/LoggingActionFilter.cs
+1
-1
Program.cs
Breeze/src/Breeze.Daemon/Program.cs
+126
-23
LightWalletFeature.cs
Breeze/src/Breeze.Wallet/LightWalletFeature.cs
+12
-11
LightWalletSyncManager.cs
Breeze/src/Breeze.Wallet/LightWalletSyncManager.cs
+7
-17
No files found.
.gitignore
View file @
8036646f
...
...
@@ -297,3 +297,4 @@ Thumbs.db
project.lock.json
/Breeze/src/Breeze.Daemon/Wallets
/Breeze/src/Breeze.Daemon/Logs
/Breeze.UI/.vscode/.BROWSE.VC.DB-wal
Breeze/Breeze.sln
View file @
8036646f
...
...
@@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin", "..\..\St
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stratis.Bitcoin.Common", "..\..\StratisBitcoinFullNode\Stratis.Bitcoin.Common\Stratis.Bitcoin.Common.csproj", "{4F9F7CF7-326C-4FC0-9EFB-209536A42030}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.Daemon", "src\Breeze.Daemon\Breeze.Daemon.csproj", "{
3F0937A2-3182-42D9-866F-3DEDEE28EC5A
}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Breeze.Daemon", "src\Breeze.Daemon\Breeze.Daemon.csproj", "{
AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D
}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -63,10 +63,10 @@ Global
{4F9F7CF7-326C-4FC0-9EFB-209536A42030}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F9F7CF7-326C-4FC0-9EFB-209536A42030}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F9F7CF7-326C-4FC0-9EFB-209536A42030}.Release|Any CPU.Build.0 = Release|Any CPU
{
3F0937A2-3182-42D9-866F-3DEDEE28EC5A
}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{
3F0937A2-3182-42D9-866F-3DEDEE28EC5A
}.Debug|Any CPU.Build.0 = Debug|Any CPU
{
3F0937A2-3182-42D9-866F-3DEDEE28EC5A
}.Release|Any CPU.ActiveCfg = Release|Any CPU
{
3F0937A2-3182-42D9-866F-3DEDEE28EC5A
}.Release|Any CPU.Build.0 = Release|Any CPU
{
AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D
}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{
AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D
}.Debug|Any CPU.Build.0 = Debug|Any CPU
{
AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D
}.Release|Any CPU.ActiveCfg = Release|Any CPU
{
AAF6163B-1BE2-48CE-9F9F-577C6D7AAB8D
}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -77,6 +77,5 @@ Global
{D16CD478-9D1E-4C69-91AD-43539E94A215} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{2490DD1A-6C14-47F2-A9C6-56761A52E2D9} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{29E411B1-5687-43EE-A71B-6CCEC2289129} = {1B724678-2B73-483E-B981-3A6733C2194E}
{3F0937A2-3182-42D9-866F-3DEDEE28EC5A} = {807563C4-7259-434D-B604-A14C3DCF8E30}
EndGlobalSection
EndGlobal
Breeze/src/Breeze.Api/LoggingActionFilter.cs
View file @
8036646f
...
...
@@ -33,7 +33,7 @@ namespace Breeze.Api
body
=
string
.
Join
(
Environment
.
NewLine
,
arguments
.
Values
);
}
this
.
logger
.
Log
Information
(
$"Received
{
request
.
Method
}
{
request
.
GetDisplayUrl
()}
. Body: '
{
body
}
'"
);
this
.
logger
.
Log
Debug
(
$"Received
{
request
.
Method
}
{
request
.
GetDisplayUrl
()}
. Body: '
{
body
}
'"
);
await
next
();
}
}
...
...
Breeze/src/Breeze.Daemon/Program.cs
View file @
8036646f
...
...
@@ -9,25 +9,79 @@ using Stratis.Bitcoin.Builder;
using
Stratis.Bitcoin.Configuration
;
using
Stratis.Bitcoin.Logging
;
using
Breeze.Wallet
;
using
NBitcoin
;
using
NBitcoin.Protocol
;
using
Stratis.Bitcoin.BlockStore
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.MemoryPool
;
using
Stratis.Bitcoin.Miner
;
using
Stratis.Bitcoin.Notifications
;
using
Stratis.Bitcoin.Utilities
;
using
Stratis.Bitcoin.Wallet
;
namespace
Breeze.Daemon
{
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
IFullNodeBuilder
fullNodeBuilder
=
null
;
if
(
args
.
Contains
(
"stratis"
))
{
// configure Full Node
Logs
.
Configure
(
Logs
.
GetLoggerFactory
(
args
));
if
(
NodeSettings
.
PrintHelp
(
args
,
Network
.
StratisMain
))
return
;
var
network
=
args
.
Contains
(
"-testnet"
)
?
InitStratisTest
()
:
Network
.
StratisMain
;
var
nodeSettings
=
NodeSettings
.
FromArguments
(
args
,
"stratis"
,
network
,
ProtocolVersion
.
ALT_PROTOCOL_VERSION
);
if
(
args
.
Contains
(
"light"
))
{
fullNodeBuilder
=
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseLightWallet
()
.
UseBlockNotification
()
.
UseTransactionNotification
()
.
UseApi
();
}
else
{
fullNodeBuilder
=
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseStratisConsensus
()
.
UseBlockStore
()
.
UseMempool
()
.
UseWallet
()
.
AddPowPosMining
()
.
UseApi
();
}
}
else
{
NodeSettings
nodeSettings
=
NodeSettings
.
FromArguments
(
args
);
var
fullNodeBuilder
=
new
FullNodeBuilder
()
if
(
args
.
Contains
(
"light"
))
{
fullNodeBuilder
=
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseLightWallet
()
.
UseBlockNotification
()
.
UseTransactionNotification
()
.
UseApi
();
}
else
{
fullNodeBuilder
=
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseConsensus
()
.
UseBlockStore
()
.
UseMempool
()
.
UseWallet
()
.
UseApi
();
}
}
// add the tumbler's settings
var
tumblerAddress
=
args
.
SingleOrDefault
(
arg
=>
arg
.
StartsWith
(
"-tumbler-uri="
));
...
...
@@ -39,8 +93,57 @@ namespace Breeze.Daemon
var
node
=
fullNodeBuilder
.
Build
();
//
start Full Node - this will also start the API
//
start Full Node - this will also start the API
node
.
Run
();
}
private
static
Network
InitStratisTest
()
{
Block
.
BlockSignature
=
true
;
Transaction
.
TimeStamp
=
true
;
var
consensus
=
Network
.
StratisMain
.
Consensus
.
Clone
();
consensus
.
PowLimit
=
new
Target
(
uint256
.
Parse
(
"0000ffff00000000000000000000000000000000000000000000000000000000"
));
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
var
pchMessageStart
=
new
byte
[
4
];
pchMessageStart
[
0
]
=
0x71
;
pchMessageStart
[
1
]
=
0x31
;
pchMessageStart
[
2
]
=
0x21
;
pchMessageStart
[
3
]
=
0x11
;
var
magic
=
BitConverter
.
ToUInt32
(
pchMessageStart
,
0
);
//0x5223570;
var
genesis
=
Network
.
StratisMain
.
GetGenesis
().
Clone
();
genesis
.
Header
.
Time
=
1493909211
;
genesis
.
Header
.
Nonce
=
2433759
;
genesis
.
Header
.
Bits
=
consensus
.
PowLimit
;
consensus
.
HashGenesisBlock
=
genesis
.
GetHash
();
Guard
.
Assert
(
consensus
.
HashGenesisBlock
==
uint256
.
Parse
(
"0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"
));
var
builder
=
new
NetworkBuilder
()
.
SetName
(
"StratisTest"
)
.
SetConsensus
(
consensus
)
.
SetMagic
(
magic
)
.
SetGenesis
(
genesis
)
.
SetPort
(
26178
)
.
SetRPCPort
(
26174
)
.
SetBase58Bytes
(
Base58Type
.
PUBKEY_ADDRESS
,
new
byte
[]
{
(
65
)
})
.
SetBase58Bytes
(
Base58Type
.
SCRIPT_ADDRESS
,
new
byte
[]
{
(
196
)
})
.
SetBase58Bytes
(
Base58Type
.
SECRET_KEY
,
new
byte
[]
{
(
65
+
128
)
})
.
SetBase58Bytes
(
Base58Type
.
ENCRYPTED_SECRET_KEY_NO_EC
,
new
byte
[]
{
0x01
,
0x42
})
.
SetBase58Bytes
(
Base58Type
.
ENCRYPTED_SECRET_KEY_EC
,
new
byte
[]
{
0x01
,
0x43
})
.
SetBase58Bytes
(
Base58Type
.
EXT_PUBLIC_KEY
,
new
byte
[]
{
(
0x04
),
(
0x88
),
(
0xB2
),
(
0x1E
)
})
.
SetBase58Bytes
(
Base58Type
.
EXT_SECRET_KEY
,
new
byte
[]
{
(
0x04
),
(
0x88
),
(
0xAD
),
(
0xE4
)
})
.
AddDNSSeeds
(
new
[]
{
new
DNSSeedData
(
"stratisplatform.com"
,
"testnode1.stratisplatform.com"
),
});
return
builder
.
BuildAndRegister
();
}
}
}
Breeze/src/Breeze.Wallet/LightWalletFeature.cs
View file @
8036646f
...
...
@@ -5,21 +5,22 @@ using Stratis.Bitcoin.Logging;
using
Microsoft.Extensions.Logging
;
using
Serilog
;
using
Stratis.Bitcoin.Wallet
;
using
Stratis.Bitcoin.Wallet.Controllers
;
namespace
Breeze.Wallet
{
public
class
LightWalletFeature
:
FullNodeFeature
{
private
readonly
TrackNotifier
trackNotifi
er
;
private
readonly
LightWalletSyncManager
lightWalletSyncManag
er
;
public
LightWalletFeature
(
TrackNotifier
trackNotifi
er
)
public
LightWalletFeature
(
LightWalletSyncManager
lightWalletSyncManag
er
)
{
this
.
trackNotifier
=
trackNotifi
er
;
this
.
lightWalletSyncManager
=
lightWalletSyncManag
er
;
}
public
override
void
Start
()
{
this
.
trackNotifier
.
Initialize
().
GetAwaiter
().
GetResult
();
this
.
lightWalletSyncManager
.
Initialize
();
}
public
override
void
Stop
()
...
...
@@ -28,20 +29,20 @@ namespace Breeze.Wallet
}
}
public
static
class
WalletFeatureExtension
public
static
class
Light
WalletFeatureExtension
{
public
static
IFullNodeBuilder
UseLightWallet
(
this
IFullNodeBuilder
fullNodeBuilder
)
{
// use the wallet and on top of that start to notifier
fullNodeBuilder
.
UseWallet
();
fullNodeBuilder
.
ConfigureFeature
(
features
=>
{
features
.
AddFeature
<
LightWalletFeature
>()
.
FeatureServices
(
services
=>
{
services
.
AddSingleton
<
TrackNotifier
>();
services
.
AddSingleton
<
IWalletSyncManager
,
LightWalletSyncManager
>();
services
.
AddSingleton
<
IWalletManager
,
WalletManager
>();
services
.
AddSingleton
<
WalletController
>();
});
});
...
...
Breeze/src/Breeze.Wallet/
TrackNotifi
er.cs
→
Breeze/src/Breeze.Wallet/
LightWalletSyncManag
er.cs
View file @
8036646f
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Reactive.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Logging
;
...
...
@@ -12,11 +8,10 @@ using Stratis.Bitcoin;
using
Stratis.Bitcoin.Notifications
;
using
Stratis.Bitcoin.Utilities
;
using
Stratis.Bitcoin.Wallet
;
using
Stratis.Bitcoin.Wallet.Notifications
;
namespace
Breeze.Wallet
{
public
class
TrackNotifi
er
public
class
LightWalletSyncManager
:
WalletSyncManag
er
{
private
readonly
WalletManager
walletManager
;
private
readonly
ConcurrentChain
chain
;
...
...
@@ -24,26 +19,21 @@ namespace Breeze.Wallet
private
readonly
CoinType
coinType
;
private
readonly
ILogger
logger
;
public
TrackNotifier
(
ILoggerFactory
loggerFactory
,
IWalletManager
walletManager
,
ConcurrentChain
chain
,
BlockNotification
blockNotification
,
Network
network
)
public
LightWalletSyncManager
(
ILoggerFactory
loggerFactory
,
IWalletManager
walletManager
,
ConcurrentChain
chain
,
Network
network
,
BlockNotification
blockNotification
):
base
(
loggerFactory
,
walletManager
,
chain
,
network
)
{
this
.
walletManager
=
walletManager
as
WalletManager
;
this
.
chain
=
chain
;
this
.
blockNotification
=
blockNotification
;
this
.
coinType
=
(
CoinType
)
network
.
Consensus
.
CoinType
;
this
.
logger
=
loggerFactory
.
CreateLogger
(
this
.
GetType
().
FullName
);
}
/// <inheritdoc />
public
Task
Initialize
()
public
override
void
Initialize
()
{
// get the chain headers. This needs to be up-to-date before we really do anything
//await this.WaitForChainDownloadAsync
();
this
.
WaitForChainDownloadAsync
().
GetAwaiter
().
GetResult
();
// start syncing blocks
var
bestHeightForSyncing
=
this
.
FindBestHeightForSyncing
();
this
.
SyncFrom
(
bestHeightForSyncing
);
return
Task
.
CompletedTask
;
}
private
int
FindBestHeightForSyncing
()
...
...
@@ -85,7 +75,7 @@ namespace Breeze.Wallet
}
/// <inheritdoc />
public
void
SyncFrom
(
DateTime
date
)
public
override
void
SyncFrom
(
DateTime
date
)
{
int
blockSyncStart
=
this
.
chain
.
GetHeightAtTime
(
date
);
...
...
@@ -94,7 +84,7 @@ namespace Breeze.Wallet
}
/// <inheritdoc />
public
void
SyncFrom
(
int
height
)
public
override
void
SyncFrom
(
int
height
)
{
this
.
blockNotification
.
SyncFrom
(
this
.
chain
.
GetBlock
(
height
).
HashBlock
);
}
...
...
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