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
1887f997
Commit
1887f997
authored
Jan 14, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge funds preservation rule
parent
12dd1aa9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
DeStreamFullNodeBuilderConsensusExtension.cs
...es.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
+2
-0
DeStreamFundsPreservationRule.cs
...sensus/Rules/CommonRules/DeStreamFundsPreservationRule.cs
+3
-3
No files found.
Sources/Stratis.Bitcoin.Features.Consensus/DeStreamFullNodeBuilderConsensusExtension.cs
View file @
1887f997
...
...
@@ -116,6 +116,7 @@ namespace Stratis.Bitcoin.Features.Consensus
// rules that require the store to be loaded (coinview)
new
DeStreamLoadCoinviewRule
(),
new
DeStreamFundsPreservationRule
(),
new
TransactionDuplicationActivationRule
(),
// implements BIP30
new
DeStreamPowCoinviewRule
(),
// implements BIP68, MaxSigOps and BlockReward calculation
new
SaveCoinviewRule
(),
...
...
@@ -174,6 +175,7 @@ namespace Stratis.Bitcoin.Features.Consensus
// rules that require the store to be loaded (coinview)
new
DeStreamLoadCoinviewRule
(),
new
DeStreamFundsPreservationRule
(),
new
TransactionDuplicationActivationRule
(),
// implements BIP30
new
DeStreamPosCoinviewRule
(),
// implements BIP68, MaxSigOps and BlockReward calculation
// Place the PosColdStakingRule after the PosCoinviewRule to ensure that all input scripts have been evaluated
...
...
Sources/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/DeStreamFundsPreservationRule.cs
View file @
1887f997
...
...
@@ -2,6 +2,7 @@
using
System.Linq
;
using
System.Threading.Tasks
;
using
NBitcoin
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Consensus.Rules
;
namespace
Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
...
...
@@ -9,7 +10,6 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
/// <summary>
/// A rule verifies that total amount of coins in blockchain is not changed
/// </summary>
[
ExecutionRule
]
public
class
DeStreamFundsPreservationRule
:
UtxoStoreConsensusRule
{
public
override
Task
RunAsync
(
RuleContext
context
)
...
...
@@ -17,12 +17,12 @@ namespace Stratis.Bitcoin.Features.Consensus.Rules.CommonRules
UnspentOutputSet
inputs
=
(
context
as
UtxoRuleContext
??
throw
new
NotSupportedException
(
$"Rule context must be
{
nameof
(
UtxoRuleContext
)}
"
)).
UnspentOutputSet
;
long
totalIn
=
context
.
ValidationContext
.
Block
.
Transactions
.
SelectMany
(
p
=>
long
totalIn
=
context
.
ValidationContext
.
Block
ToValidate
.
Transactions
.
SelectMany
(
p
=>
p
.
Inputs
.
RemoveChangePointer
().
Where
(
q
=>
q
.
PrevOut
!=
null
)
.
Select
(
q
=>
inputs
.
AccessCoins
(
q
.
PrevOut
.
Hash
)?.
TryGetOutput
(
q
.
PrevOut
.
N
)?.
Value
??
0
))
.
Sum
(
p
=>
p
??
0
);
long
totalOut
=
context
.
ValidationContext
.
Block
.
Transactions
.
SelectMany
(
p
=>
p
.
Outputs
.
Select
(
q
=>
q
.
Value
))
long
totalOut
=
context
.
ValidationContext
.
Block
ToValidate
.
Transactions
.
SelectMany
(
p
=>
p
.
Outputs
.
Select
(
q
=>
q
.
Value
))
.
Sum
(
p
=>
p
);
if
(
totalIn
!=
totalOut
)
...
...
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