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
d16395c8
Commit
d16395c8
authored
Nov 19, 2018
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify fee validation in mempool
Transaction fee is validated before accepting transaction to mempool
parent
fe545d5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
DeStreamMempoolValidator.cs
...s.Bitcoin.Features.MemoryPool/DeStreamMempoolValidator.cs
+19
-1
MempoolValidator.cs
...s/Stratis.Bitcoin.Features.MemoryPool/MempoolValidator.cs
+2
-2
No files found.
Sources/Stratis.Bitcoin.Features.MemoryPool/DeStreamMempoolValidator.cs
View file @
d16395c8
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
NBitcoin
;
using
NBitcoin
;
...
@@ -186,5 +188,21 @@ namespace Stratis.Bitcoin.Features.MemoryPool
...
@@ -186,5 +188,21 @@ namespace Stratis.Bitcoin.Features.MemoryPool
context
.
SetConflicts
.
Add
(
ptxConflicting
.
GetHash
());
context
.
SetConflicts
.
Add
(
ptxConflicting
.
GetHash
());
}
}
}
}
/// <summary>
/// Validates the transaction fee is valid.
/// </summary>
/// <param name="context">Current validation context.</param>
protected
override
void
CheckFee
(
MempoolValidationContext
context
)
{
long
expectedFee
=
Convert
.
ToInt64
(
context
.
Transaction
.
Outputs
.
Where
(
p
=>
!
context
.
Transaction
.
Inputs
.
RemoveChangePointer
()
.
Select
(
q
=>
context
.
View
.
Set
.
GetOutputFor
(
q
).
ScriptPubKey
)
.
Contains
(
p
.
ScriptPubKey
))
.
Sum
(
p
=>
p
.
Value
)
*
this
.
network
.
FeeRate
);
if
(
context
.
ModifiedFees
<
expectedFee
)
context
.
State
.
Fail
(
MempoolErrors
.
InsufficientFee
,
$"
{
context
.
Fees
}
<
{
expectedFee
}
"
).
Throw
();
}
}
}
}
}
\ No newline at end of file
Sources/Stratis.Bitcoin.Features.MemoryPool/MempoolValidator.cs
View file @
d16395c8
...
@@ -153,7 +153,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
...
@@ -153,7 +153,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
// public long LastTime;
// public long LastTime;
//}
//}
pr
ivate
Network
network
;
pr
otected
Network
network
;
/// <summary>
/// <summary>
/// Constructs a memory pool validator object.
/// Constructs a memory pool validator object.
...
@@ -697,7 +697,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
...
@@ -697,7 +697,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// and absurdly high fees.
/// and absurdly high fees.
/// </summary>
/// </summary>
/// <param name="context">Current validation context.</param>
/// <param name="context">Current validation context.</param>
protected
void
CheckFee
(
MempoolValidationContext
context
)
protected
v
irtual
v
oid
CheckFee
(
MempoolValidationContext
context
)
{
{
Money
mempoolRejectFee
=
this
.
memPool
.
GetMinFee
(
this
.
mempoolSettings
.
MaxMempool
*
1000000
).
GetFee
(
context
.
EntrySize
);
Money
mempoolRejectFee
=
this
.
memPool
.
GetMinFee
(
this
.
mempoolSettings
.
MaxMempool
*
1000000
).
GetFee
(
context
.
EntrySize
);
if
(
mempoolRejectFee
>
0
&&
context
.
ModifiedFees
<
mempoolRejectFee
)
if
(
mempoolRejectFee
>
0
&&
context
.
ModifiedFees
<
mempoolRejectFee
)
...
...
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