Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
destream-blockchain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
destream-blockchain
Commits
c71f8bc6
Commit
c71f8bc6
authored
Jan 14, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge DBreeze CoinView
parent
314a3e0b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
37 deletions
+29
-37
DBreezeCoinView.cs
...s.Bitcoin.Features.Consensus/CoinViews/DBreezeCoinView.cs
+5
-5
DeStreamDBreezeCoinView.cs
...n.Features.Consensus/CoinViews/DeStreamDBreezeCoinView.cs
+20
-28
DeStreamFullNodeBuilderConsensusExtension.cs
...es.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
+4
-4
No files found.
Sources/Stratis.Bitcoin.Features.Consensus/CoinViews/DBreezeCoinView.cs
View file @
c71f8bc6
...
...
@@ -24,10 +24,10 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
private
static
readonly
byte
[]
blockHashKey
=
new
byte
[
0
];
/// <summary>Instance logger.</summary>
pr
ivate
readonly
ILogger
logger
;
pr
otected
readonly
ILogger
logger
;
/// <summary>Specification of the network the node runs on - regtest/testnet/mainnet.</summary>
pr
ivate
readonly
Network
network
;
pr
otected
readonly
Network
network
;
/// <summary>Hash of the block which is currently the tip of the coinview.</summary>
private
uint256
blockHash
;
...
...
@@ -78,7 +78,7 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
/// <summary>
/// Initializes the database tables used by the coinview.
/// </summary>
public
Task
InitializeAsync
()
public
virtual
Task
InitializeAsync
()
{
Block
genesis
=
this
.
network
.
GetGenesis
();
...
...
@@ -164,7 +164,7 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
/// </summary>
/// <param name="transaction">Open dBreeze transaction.</param>
/// <returns>Block header hash of the coinview's current tip.</returns>
pr
ivate
uint256
GetTipHash
(
DBreeze
.
Transactions
.
Transaction
transaction
)
pr
otected
uint256
GetTipHash
(
DBreeze
.
Transactions
.
Transaction
transaction
)
{
if
(
this
.
blockHash
==
null
)
{
...
...
@@ -181,7 +181,7 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
/// </summary>
/// <param name="transaction">Open dBreeze transaction.</param>
/// <param name="nextBlockHash">Hash of the block to become the new tip.</param>
pr
ivate
void
SetBlockHash
(
DBreeze
.
Transactions
.
Transaction
transaction
,
uint256
nextBlockHash
)
pr
otected
void
SetBlockHash
(
DBreeze
.
Transactions
.
Transaction
transaction
,
uint256
nextBlockHash
)
{
this
.
blockHash
=
nextBlockHash
;
transaction
.
Insert
<
byte
[],
uint256
>(
"BlockHash"
,
blockHashKey
,
nextBlockHash
);
...
...
Sources/Stratis.Bitcoin.Features.Consensus/CoinViews/DeStreamDBreezeCoinView.cs
View file @
c71f8bc6
...
...
@@ -13,35 +13,33 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
public
class
DeStreamDBreezeCoinView
:
DBreezeCoinView
,
IDisposable
{
public
DeStreamDBreezeCoinView
(
Network
network
,
DataFolder
dataFolder
,
IDateTimeProvider
dateTimeProvider
,
ILoggerFactory
loggerFactory
)
:
base
(
network
,
dataFolder
,
dateTimeProvider
,
loggerFactory
)
ILoggerFactory
loggerFactory
,
INodeStats
nodeStats
)
:
base
(
network
,
dataFolder
,
dateTimeProvider
,
loggerFactory
,
nodeStats
)
{
}
public
DeStreamDBreezeCoinView
(
Network
network
,
string
folder
,
IDateTimeProvider
dateTimeProvider
,
ILoggerFactory
loggerFactory
)
:
base
(
network
,
folder
,
dateTimeProvider
,
loggerFactory
)
ILoggerFactory
loggerFactory
,
INodeStats
nodeStats
)
:
base
(
network
,
folder
,
dateTimeProvider
,
loggerFactory
,
nodeStats
)
{
}
/// <inheritdoc />
// Instead of ignoring genesis coins, add them to database
public
override
Task
InitializeAsync
()
{
this
.
logger
.
LogTrace
(
"()"
);
var
genesis
=
this
.
network
.
GetGenesis
(
);
Block
genesis
=
this
.
network
.
GetGenesis
();
int
insertedEntities
=
0
;
Task
task
=
Task
.
Run
(()
=>
var
task
=
Task
.
Run
(()
=>
{
this
.
logger
.
LogTrace
(
"()"
);
using
(
Transaction
transaction
=
this
.
dbreeze
.
GetTransaction
())
using
(
Transaction
transaction
=
CreateTransaction
())
{
transaction
.
ValuesLazyLoadingIsOn
=
false
;
transaction
.
SynchronizeTables
(
"BlockHash"
);
if
(
this
.
GetCurrentHash
(
transaction
)
==
null
)
{
if
(
this
.
GetTipHash
(
transaction
)
!=
null
)
return
;
this
.
SetBlockHash
(
transaction
,
genesis
.
GetHash
());
// Genesis coin is spendable and added to the database.
...
...
@@ -52,16 +50,10 @@ namespace Stratis.Bitcoin.Features.Consensus.CoinViews
unspentOutput
.
ToCoins
());
}
insertedEntities
+=
genesis
.
Transactions
.
Count
;
transaction
.
Commit
();
}
}
this
.
logger
.
LogTrace
(
"(-)"
);
});
this
.
PerformanceCounter
.
AddInsertedEntities
(
insertedEntities
);
this
.
logger
.
LogTrace
(
"(-)"
);
return
task
;
}
}
...
...
Sources/Stratis.Bitcoin.Features.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
View file @
c71f8bc6
...
...
@@ -22,7 +22,7 @@ namespace Stratis.Bitcoin.Features.Consensus
/// </summary>
public
static
class
DeStreamFullNodeBuilderConsensusExtension
{
public
static
IFullNodeBuilder
UsePowConsensus
(
this
IFullNodeBuilder
fullNodeBuilder
)
public
static
IFullNodeBuilder
Use
DeStream
PowConsensus
(
this
IFullNodeBuilder
fullNodeBuilder
)
{
LoggingConfiguration
.
RegisterFeatureNamespace
<
PowConsensusFeature
>(
"powconsensus"
);
...
...
@@ -33,7 +33,7 @@ namespace Stratis.Bitcoin.Features.Consensus
.
FeatureServices
(
services
=>
{
services
.
AddSingleton
<
ConsensusOptions
,
ConsensusOptions
>();
services
.
AddSingleton
<
DBreezeCoinView
>();
services
.
AddSingleton
<
D
eStreamD
BreezeCoinView
>();
services
.
AddSingleton
<
ICoinView
,
CachedCoinView
>();
services
.
AddSingleton
<
ConsensusController
>();
services
.
AddSingleton
<
IConsensusRuleEngine
,
PowConsensusRuleEngine
>();
...
...
@@ -48,7 +48,7 @@ namespace Stratis.Bitcoin.Features.Consensus
return
fullNodeBuilder
;
}
public
static
IFullNodeBuilder
UsePosConsensus
(
this
IFullNodeBuilder
fullNodeBuilder
)
public
static
IFullNodeBuilder
Use
DeStream
PosConsensus
(
this
IFullNodeBuilder
fullNodeBuilder
)
{
LoggingConfiguration
.
RegisterFeatureNamespace
<
PosConsensusFeature
>(
"posconsensus"
);
...
...
@@ -58,7 +58,7 @@ namespace Stratis.Bitcoin.Features.Consensus
.
AddFeature
<
PosConsensusFeature
>()
.
FeatureServices
(
services
=>
{
services
.
AddSingleton
<
DBreezeCoinView
>();
services
.
AddSingleton
<
D
eStreamD
BreezeCoinView
>();
services
.
AddSingleton
<
ICoinView
,
CachedCoinView
>();
services
.
AddSingleton
<
StakeChainStore
>().
AddSingleton
<
IStakeChain
,
StakeChainStore
>(
provider
=>
provider
.
GetService
<
StakeChainStore
>());
services
.
AddSingleton
<
IStakeValidator
,
StakeValidator
>();
...
...
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