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
a8839265
Commit
a8839265
authored
Jan 14, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge consensus rule context and base
parent
f4f13dc1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
28 deletions
+37
-28
DeStreamPosCoinViewRuleTests.cs
...s.Tests/Rules/CommonRules/DeStreamPosCoinViewRuleTests.cs
+1
-1
DeStreamFullNodeBuilderConsensusExtension.cs
...es.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
+2
-2
DeStreamRuleContextOverrides.cs
...itcoin.Features.Consensus/DeStreamRuleContextOverrides.cs
+15
-9
DeStreamConsensusRules.cs
...itcoin.Features.Consensus/Rules/DeStreamConsensusRules.cs
+19
-16
No files found.
Sources/Stratis.Bitcoin.Features.Consensus.Tests/Rules/CommonRules/DeStreamPosCoinViewRuleTests.cs
View file @
a8839265
...
...
@@ -38,7 +38,7 @@ namespace Stratis.Bitcoin.Features.Consensus.Tests.Rules.CommonRules
// Register POS consensus rules.
new
DeStreamFullNodeBuilderConsensusExtension
.
PosConsensusRulesRegistration
().
RegisterRules
(
this
.
network
.
Consensus
);
ConsensusRuleEngine
consensusRuleEngine
=
new
PosConsensusRuleEngine
(
this
.
network
,
this
.
loggerFactory
.
Object
,
DateTimeProvider
.
Default
,
ConsensusRuleEngine
consensusRuleEngine
=
new
DeStream
PosConsensusRuleEngine
(
this
.
network
,
this
.
loggerFactory
.
Object
,
DateTimeProvider
.
Default
,
this
.
concurrentChain
,
this
.
nodeDeployments
,
this
.
consensusSettings
,
this
.
checkpoints
.
Object
,
this
.
coinView
.
Object
,
this
.
stakeChain
.
Object
,
this
.
stakeValidator
.
Object
,
this
.
chainState
.
Object
,
new
InvalidBlockHashStore
(
this
.
dateTimeProvider
.
Object
),
new
Mock
<
INodeStats
>().
Object
,
this
.
rewindDataIndexStore
.
Object
)
.
Register
();
...
...
Sources/Stratis.Bitcoin.Features.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
View file @
a8839265
...
...
@@ -36,7 +36,7 @@ namespace Stratis.Bitcoin.Features.Consensus
services
.
AddSingleton
<
DeStreamDBreezeCoinView
>();
services
.
AddSingleton
<
ICoinView
,
CachedCoinView
>();
services
.
AddSingleton
<
ConsensusController
>();
services
.
AddSingleton
<
IConsensusRuleEngine
,
PowConsensusRuleEngine
>();
services
.
AddSingleton
<
IConsensusRuleEngine
,
DeStream
PowConsensusRuleEngine
>();
services
.
AddSingleton
<
IChainState
,
ChainState
>();
services
.
AddSingleton
<
ConsensusQuery
>()
.
AddSingleton
<
INetworkDifficulty
,
ConsensusQuery
>(
provider
=>
provider
.
GetService
<
ConsensusQuery
>())
...
...
@@ -64,7 +64,7 @@ namespace Stratis.Bitcoin.Features.Consensus
services
.
AddSingleton
<
IStakeValidator
,
StakeValidator
>();
services
.
AddSingleton
<
ConsensusController
>();
services
.
AddSingleton
<
IRewindDataIndexCache
,
RewindDataIndexCache
>();
services
.
AddSingleton
<
IConsensusRuleEngine
,
PosConsensusRuleEngine
>();
services
.
AddSingleton
<
IConsensusRuleEngine
,
DeStream
PosConsensusRuleEngine
>();
services
.
AddSingleton
<
IChainState
,
ChainState
>();
services
.
AddSingleton
<
ConsensusQuery
>()
.
AddSingleton
<
INetworkDifficulty
,
ConsensusQuery
>(
provider
=>
provider
.
GetService
<
ConsensusQuery
>())
...
...
Sources/Stratis.Bitcoin.Features.Consensus/DeStreamRuleContextOverrides.cs
View file @
a8839265
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
NBitcoin
;
using
Stratis.Bitcoin.Consensus
;
...
...
@@ -7,25 +8,30 @@ namespace Stratis.Bitcoin.Features.Consensus
public
interface
IDeStreamRuleContext
{
/// <summary>
///
S
criptPubKeys of inputs spent in transaction
///
Gets or sets s
criptPubKeys of inputs spent in transaction
/// </summary>
IDictionary
<
uint256
,
List
<
Script
>>
InputScriptPubKeys
{
get
;
set
;
}
/// <summary>
///
S
um of inputs spent in transaction
///
Gets or sets s
um of inputs spent in transaction
/// </summary>
IDictionary
<
uint256
,
Money
>
TotalIn
{
get
;
set
;
}
}
/// <inheritdoc cref="PosRuleContext" />
public
class
DeStreamRuleContext
:
PosRuleContext
,
IDeStreamRuleContext
public
class
DeStream
Pos
RuleContext
:
PosRuleContext
,
IDeStreamRuleContext
{
internal
DeStreamRuleContext
()
internal
DeStream
Pos
RuleContext
()
{
}
public
DeStreamRuleContext
(
ValidationContext
validationContext
,
NBitcoin
.
Consensus
consensus
,
ChainedHeader
consensusTip
)
:
base
(
validationContext
,
consensus
,
consensusTip
)
public
DeStreamPosRuleContext
(
BlockStake
blockStake
)
:
base
(
blockStake
)
{
}
public
DeStreamPosRuleContext
(
ValidationContext
validationContext
,
DateTimeOffset
time
)
:
base
(
validationContext
,
time
)
{
}
...
...
@@ -44,8 +50,8 @@ namespace Stratis.Bitcoin.Features.Consensus
{
}
public
DeStreamPowRuleContext
(
ValidationContext
validationContext
,
NBitcoin
.
Consensus
consensus
,
ChainedHeader
consensusTip
)
:
base
(
validationContext
,
consensus
,
consensusTip
)
public
DeStreamPowRuleContext
(
ValidationContext
validationContext
,
DateTimeOffset
time
)
:
base
(
validationContext
,
time
)
{
}
...
...
Sources/Stratis.Bitcoin.Features.Consensus/Rules/DeStreamConsensusRules.cs
View file @
a8839265
using
Microsoft.Extensions.Logging
;
using
NBitcoin
;
using
Stratis.Bitcoin.Base
;
using
Stratis.Bitcoin.Base.Deployments
;
using
Stratis.Bitcoin.BlockPulling
;
using
Stratis.Bitcoin.Configuration.Settings
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Consensus.Rules
;
using
Stratis.Bitcoin.Features.Consensus.CoinViews
;
using
Stratis.Bitcoin.Features.Consensus.Interfaces
;
using
Stratis.Bitcoin.Features.Consensus.ProvenBlockHeaders
;
using
Stratis.Bitcoin.Utilities
;
namespace
Stratis.Bitcoin.Features.Consensus.Rules
{
public
class
DeStreamPowConsensusRule
s
:
PowConsensusRules
public
class
DeStreamPowConsensusRule
Engine
:
PowConsensusRuleEngine
{
public
DeStreamPowConsensusRule
s
(
Network
network
,
ILoggerFactory
loggerFactory
,
public
DeStreamPowConsensusRule
Engine
(
Network
network
,
ILoggerFactory
loggerFactory
,
IDateTimeProvider
dateTimeProvider
,
ConcurrentChain
chain
,
NodeDeployments
nodeDeployments
,
ConsensusSettings
consensusSettings
,
ICheckpoints
checkpoints
,
CoinView
utxoSet
,
ILookaheadBlockPuller
puller
)
:
base
(
network
,
loggerFactory
,
dateTimeProvider
,
chain
,
nodeDeployments
,
consensusSettings
,
checkpoints
,
utxoSet
,
puller
)
ConsensusSettings
consensusSettings
,
ICheckpoints
checkpoints
,
ICoinView
utxoSet
,
IChainState
chainState
,
IInvalidBlockHashStore
invalidBlockHashStore
,
INodeStats
nodeStats
)
:
base
(
network
,
loggerFactory
,
dateTimeProvider
,
chain
,
nodeDeployments
,
consensusSettings
,
checkpoints
,
utxoSet
,
chainState
,
invalidBlockHashStore
,
nodeStats
)
{
}
public
override
RuleContext
CreateRuleContext
(
ValidationContext
validationContext
,
ChainedHeader
consensusTip
)
public
override
RuleContext
CreateRuleContext
(
ValidationContext
validationContext
)
{
return
new
DeStreamPowRuleContext
(
validationContext
,
this
.
Network
.
Consensus
,
consensusTip
);
return
new
DeStreamPowRuleContext
(
validationContext
,
DateTimeProvider
.
GetTimeOffset
()
);
}
}
public
class
DeStreamPosConsensusRule
s
:
PosConsensusRules
public
class
DeStreamPosConsensusRule
Engine
:
PosConsensusRuleEngine
{
public
DeStreamPosConsensusRule
s
(
Network
network
,
ILoggerFactory
loggerFactory
,
public
DeStreamPosConsensusRule
Engine
(
Network
network
,
ILoggerFactory
loggerFactory
,
IDateTimeProvider
dateTimeProvider
,
ConcurrentChain
chain
,
NodeDeployments
nodeDeployments
,
ConsensusSettings
consensusSettings
,
ICheckpoints
checkpoints
,
CoinView
utxoSet
,
ILookaheadBlockPuller
puller
,
IStakeChain
stakeChain
,
IStakeValidator
stakeValidator
)
:
base
(
network
,
loggerFactory
,
dateTimeProvider
,
chain
,
nodeDeployments
,
consensusSettings
,
checkpoints
,
utxoSet
,
puller
,
stakeChain
,
stakeValidator
)
ConsensusSettings
consensusSettings
,
ICheckpoints
checkpoints
,
ICoinView
utxoSet
,
IStakeChain
stakeChain
,
IStakeValidator
stakeValidator
,
IChainState
chainState
,
IInvalidBlockHashStore
invalidBlockHashStore
,
INodeStats
nodeStats
,
IRewindDataIndexCache
rewindDataIndexCache
)
:
base
(
network
,
loggerFactory
,
dateTimeProvider
,
chain
,
nodeDeployments
,
consensusSettings
,
checkpoints
,
utxoSet
,
stakeChain
,
stakeValidator
,
chainState
,
invalidBlockHashStore
,
nodeStats
,
rewindDataIndexCache
)
{
}
public
override
RuleContext
CreateRuleContext
(
ValidationContext
validationContext
,
ChainedHeader
consensusTip
)
public
override
RuleContext
CreateRuleContext
(
ValidationContext
validationContext
)
{
return
new
DeStream
RuleContext
(
validationContext
,
this
.
Network
.
Consensus
,
consensusTip
);
return
new
DeStream
PosRuleContext
(
validationContext
,
DateTimeProvider
.
GetTimeOffset
()
);
}
}
}
\ No newline at end of file
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