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
30d9620f
Commit
30d9620f
authored
Jan 16, 2019
by
Sergei Zubov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge mempool
parent
73ee2662
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
78 deletions
+85
-78
Stratis.Bitcoin.Features.MemoryPool.Tests.csproj
...ol.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj
+2
-10
DeStreamFullNodeBuilderMemoryPoolExtension.cs
....MemoryPool/DeStreamFullNodeBuilderMemoryPoolExtension.cs
+1
-1
DeStreamMempoolCoinView.cs
...is.Bitcoin.Features.MemoryPool/DeStreamMempoolCoinView.cs
+14
-6
DeStreamMempoolManager.cs
...tis.Bitcoin.Features.MemoryPool/DeStreamMempoolManager.cs
+9
-8
DeStreamMempoolValidator.cs
...s.Bitcoin.Features.MemoryPool/DeStreamMempoolValidator.cs
+34
-28
MemPoolCoinView.cs
...es/Stratis.Bitcoin.Features.MemoryPool/MemPoolCoinView.cs
+4
-4
MempoolManager.cs
...ces/Stratis.Bitcoin.Features.MemoryPool/MempoolManager.cs
+3
-3
MempoolValidator.cs
...s/Stratis.Bitcoin.Features.MemoryPool/MempoolValidator.cs
+18
-18
No files found.
Sources/Stratis.Bitcoin.Features.MemoryPool.Tests/Stratis.Bitcoin.Features.MemoryPool.Tests.csproj
View file @
30d9620f
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.MemoryPool.Tests</AssemblyName>
...
...
@@ -16,17 +15,14 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<CodeAnalysisRuleSet>..\None.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
<EmbeddedResource Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
<None Remove="Stratis.Bitcoin.Features.MemoryPool.Tests\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DBreeze" Version="1.89.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
...
...
@@ -35,7 +31,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.BlockStore\Stratis.Bitcoin.Features.BlockStore.csproj" />
...
...
@@ -45,15 +40,12 @@
<ProjectReference Include="..\Stratis.Bitcoin.Tests.Common\Stratis.Bitcoin.Tests.Common.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
\ No newline at end of file
Sources/Stratis.Bitcoin.Features.MemoryPool/DeStreamFullNodeBuilderMemoryPoolExtension.cs
View file @
30d9620f
Sources/Stratis.Bitcoin.Features.MemoryPool/DeStreamMempoolCoinView.cs
View file @
30d9620f
...
...
@@ -11,11 +11,13 @@ using Stratis.Bitcoin.Utilities;
namespace
Stratis.Bitcoin.Features.MemoryPool
{
/// <summary>
///
Creates <see cref="DeStreamUnspentOutputSet"
/> and ChangePointer input
///
Creates <see cref="DeStreamUnspentOutputSet"
/> and ChangePointer input
/// </summary>
public
class
DeStreamMempoolCoinView
:
MempoolCoinView
{
public
DeStreamMempoolCoinView
(
CoinView
inner
,
ITxMempool
memPool
,
SchedulerLock
mempoolLock
,
IMempoolValidator
mempoolValidator
)
:
base
(
inner
,
memPool
,
mempoolLock
,
mempoolValidator
)
public
DeStreamMempoolCoinView
(
ICoinView
inner
,
ITxMempool
memPool
,
SchedulerLock
mempoolLock
,
IMempoolValidator
mempoolValidator
)
:
base
(
inner
,
memPool
,
mempoolLock
,
mempoolValidator
)
{
this
.
Set
=
new
DeStreamUnspentOutputSet
();
}
...
...
@@ -23,15 +25,21 @@ namespace Stratis.Bitcoin.Features.MemoryPool
public
override
async
Task
LoadViewAsync
(
Transaction
trx
)
{
// lookup all ids (duplicate ids are ignored in case a trx spends outputs from the same parent).
List
<
uint256
>
ids
=
trx
.
Inputs
.
RemoveChangePointer
().
Select
(
n
=>
n
.
PrevOut
.
Hash
).
Distinct
().
Concat
(
new
[]
{
trx
.
GetHash
()
}).
ToList
();
List
<
uint256
>
ids
=
trx
.
Inputs
.
RemoveChangePointer
().
Select
(
n
=>
n
.
PrevOut
.
Hash
).
Distinct
()
.
Concat
(
new
[]
{
trx
.
GetHash
()}).
ToList
();
FetchCoinsResponse
coins
=
await
this
.
Inner
.
FetchCoinsAsync
(
ids
.
ToArray
());
// find coins currently in the mempool
List
<
Transaction
>
mempoolcoins
=
await
this
.
mempoolLock
.
ReadAsync
(()
=>
{
return
this
.
memPool
.
MapTx
.
Values
.
Where
(
t
=>
ids
.
Contains
(
t
.
TransactionHash
)).
Select
(
s
=>
s
.
Transaction
).
ToList
();
return
this
.
memPool
.
MapTx
.
Values
.
Where
(
t
=>
ids
.
Contains
(
t
.
TransactionHash
))
.
Select
(
s
=>
s
.
Transaction
).
ToList
();
});
IEnumerable
<
UnspentOutputs
>
memOutputs
=
mempoolcoins
.
Select
(
s
=>
new
UnspentOutputs
(
TxMempool
.
MempoolHeight
,
s
));
coins
=
new
FetchCoinsResponse
(
coins
.
UnspentOutputs
.
Concat
(
memOutputs
).
Append
(
new
UnspentOutputs
(
uint256
.
Zero
,
new
Coins
(
new
Transaction
(),
0
))).
ToArray
(),
coins
.
BlockHash
);
IEnumerable
<
UnspentOutputs
>
memOutputs
=
mempoolcoins
.
Select
(
s
=>
new
UnspentOutputs
(
TxMempool
.
MempoolHeight
,
s
));
coins
=
new
FetchCoinsResponse
(
coins
.
UnspentOutputs
.
Concat
(
memOutputs
)
.
Append
(
new
UnspentOutputs
(
uint256
.
Zero
,
new
Coins
(
new
Transaction
(),
0
))).
ToArray
(),
coins
.
BlockHash
);
// the UTXO set might have been updated with a recently received block
// but the block has not yet arrived to the mempool and remove the pending trx
...
...
Sources/Stratis.Bitcoin.Features.MemoryPool/DeStreamMempoolManager.cs
View file @
30d9620f
...
...
@@ -8,22 +8,23 @@ using Stratis.Bitcoin.Utilities;
namespace
Stratis.Bitcoin.Features.MemoryPool
{
/// <summary>
///
Creates <see cref="DeStreamMempoolCoinView"
/>
///
Creates <see cref="DeStreamMempoolCoinView"
/>
/// </summary>
public
class
DeStreamMempoolManager
:
MempoolManager
{
public
DeStreamMempoolManager
(
MempoolSchedulerLock
mempoolLock
,
ITxMempool
memPool
,
IMempoolValidator
validator
,
IDateTimeProvider
dateTimeProvider
,
MempoolSettings
mempoolSettings
,
IMempoolPersistence
mempoolPersistence
,
CoinView
coinView
,
ILoggerFactory
loggerFactory
,
Network
network
)
:
base
(
mempoolLock
,
memPool
,
validator
,
dateTimeProvider
,
mempoolSettings
,
mempoolPersistence
,
coinView
,
loggerFactory
,
network
)
public
DeStreamMempoolManager
(
MempoolSchedulerLock
mempoolLock
,
ITxMempool
memPool
,
IMempoolValidator
validator
,
IDateTimeProvider
dateTimeProvider
,
MempoolSettings
mempoolSettings
,
IMempoolPersistence
mempoolPersistence
,
ICoinView
coinView
,
ILoggerFactory
loggerFactory
,
Network
network
)
:
base
(
mempoolLock
,
memPool
,
validator
,
dateTimeProvider
,
mempoolSettings
,
mempoolPersistence
,
coinView
,
loggerFactory
,
network
)
{
}
public
override
async
Task
<
UnspentOutputs
>
GetUnspentTransactionAsync
(
uint256
trxid
)
{
TxMempoolInfo
txInfo
=
await
this
.
InfoAsync
(
trxid
);
if
(
txInfo
==
null
)
{
return
null
;
}
var
memPoolCoinView
=
new
DeStreamMempoolCoinView
(
this
.
coinView
,
this
.
memPool
,
this
.
MempoolLock
,
this
.
Validator
);
TxMempoolInfo
txInfo
=
await
InfoAsync
(
trxid
);
if
(
txInfo
==
null
)
return
null
;
var
memPoolCoinView
=
new
DeStreamMempoolCoinView
(
this
.
coinView
,
this
.
memPool
,
this
.
MempoolLock
,
this
.
Validator
);
await
memPoolCoinView
.
LoadViewAsync
(
txInfo
.
Trx
);
return
memPoolCoinView
.
GetCoins
(
trxid
);
}
...
...
Sources/Stratis.Bitcoin.Features.MemoryPool/DeStreamMempoolValidator.cs
View file @
30d9620f
...
...
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using
Microsoft.Extensions.Logging
;
using
NBitcoin
;
using
Stratis.Bitcoin.Configuration
;
using
Stratis.Bitcoin.Consensus
.Rules
;
using
Stratis.Bitcoin.Consensus
;
using
Stratis.Bitcoin.Features.Consensus.CoinViews
;
using
Stratis.Bitcoin.Features.MemoryPool.Interfaces
;
using
Stratis.Bitcoin.Utilities
;
...
...
@@ -19,18 +19,28 @@ namespace Stratis.Bitcoin.Features.MemoryPool
{
public
DeStreamMempoolValidator
(
ITxMempool
memPool
,
MempoolSchedulerLock
mempoolLock
,
IDateTimeProvider
dateTimeProvider
,
MempoolSettings
mempoolSettings
,
ConcurrentChain
chain
,
CoinView
coinView
,
ILoggerFactory
loggerFactory
,
NodeSettings
nodeSettings
,
IConsensusRules
consensusRules
)
:
base
(
memPool
,
mempoolLock
,
dateTimeProvider
,
mempoolSettings
,
chain
,
coinView
,
loggerFactory
,
nodeSettings
,
consensusRules
)
ICoinView
coinView
,
ILoggerFactory
loggerFactory
,
NodeSettings
nodeSettings
,
IConsensusRuleEngine
consensusRules
)
:
base
(
memPool
,
mempoolLock
,
dateTimeProvider
,
mempoolSettings
,
chain
,
coinView
,
loggerFactory
,
nodeSettings
,
consensusRules
)
{
}
private
DeStreamNetwork
DeStreamNetwork
{
get
{
if
(!(
this
.
network
is
DeStreamNetwork
))
throw
new
NotSupportedException
(
$"Network must be
{
nameof
(
NBitcoin
.
DeStreamNetwork
)}
"
);
return
(
DeStreamNetwork
)
this
.
network
;
}
}
protected
override
async
Task
AcceptToMemoryPoolWorkerAsync
(
MempoolValidationState
state
,
Transaction
tx
,
List
<
uint256
>
vHashTxnToUncache
)
{
var
context
=
new
MempoolValidationContext
(
tx
,
state
);
this
.
PreMempoolChecks
(
context
);
PreMempoolChecks
(
context
);
// create the MemPoolCoinView and load relevant utxoset
context
.
View
=
new
DeStreamMempoolCoinView
(
this
.
coinView
,
this
.
memPool
,
this
.
mempoolLock
,
this
);
...
...
@@ -45,33 +55,31 @@ namespace Stratis.Bitcoin.Features.MemoryPool
state
.
Invalid
(
MempoolErrors
.
InPool
).
Throw
();
// Check for conflicts with in-memory transactions
this
.
CheckConflicts
(
context
);
CheckConflicts
(
context
);
this
.
CheckMempoolCoinView
(
context
);
CheckMempoolCoinView
(
context
);
this
.
CreateMempoolEntry
(
context
,
state
.
AcceptTime
);
this
.
CheckSigOps
(
context
);
this
.
CheckFee
(
context
);
CreateMempoolEntry
(
context
,
state
.
AcceptTime
);
CheckSigOps
(
context
);
CheckFee
(
context
);
this
.
CheckRateLimit
(
context
,
state
.
LimitFree
);
CheckRateLimit
(
context
,
state
.
LimitFree
);
this
.
CheckAncestors
(
context
);
this
.
CheckReplacment
(
context
);
this
.
CheckAllInputs
(
context
);
CheckAncestors
(
context
);
CheckReplacment
(
context
);
CheckAllInputs
(
context
);
// Remove conflicting transactions from the mempool
foreach
(
TxMempoolEntry
it
in
context
.
AllConflicting
)
{
this
.
logger
.
LogInformation
(
$"replacing tx
{
it
.
TransactionHash
}
with
{
context
.
TransactionHash
}
for
{
context
.
ModifiedFees
-
context
.
ConflictingFees
}
BTC additional fees,
{
context
.
EntrySize
-
context
.
ConflictingSize
}
delta bytes"
);
}
this
.
memPool
.
RemoveStaged
(
context
.
AllConflicting
,
false
);
// This transaction should only count for fee estimation if
// the node is not behind and it is not dependent on any other
// transactions in the mempool
bool
validForFeeEstimation
=
this
.
IsCurrentForFeeEstimation
()
&&
this
.
memPool
.
HasNoInputsOf
(
tx
);
bool
validForFeeEstimation
=
IsCurrentForFeeEstimation
()
&&
this
.
memPool
.
HasNoInputsOf
(
tx
);
// Store transaction in memory
this
.
memPool
.
AddUnchecked
(
context
.
TransactionHash
,
context
.
Entry
,
context
.
SetAncestors
,
...
...
@@ -80,7 +88,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
// trim mempool and check if tx was trimmed
if
(!
state
.
OverrideMempoolLimit
)
{
this
.
LimitMempoolSize
(
this
.
mempoolSettings
.
MaxMempool
*
1000000
,
LimitMempoolSize
(
this
.
mempoolSettings
.
MaxMempool
*
1000000
,
this
.
mempoolSettings
.
MempoolExpiry
*
60
*
60
);
if
(!
this
.
memPool
.
Exists
(
context
.
TransactionHash
))
...
...
@@ -172,7 +180,6 @@ namespace Stratis.Bitcoin.Features.MemoryPool
// insecure.
bool
replacementOptOut
=
true
;
if
(
this
.
mempoolSettings
.
EnableReplacement
)
{
foreach
(
TxIn
txiner
in
ptxConflicting
.
Inputs
)
{
if
(
txiner
.
Sequence
>=
Sequence
.
Final
-
1
)
continue
;
...
...
@@ -180,7 +187,6 @@ namespace Stratis.Bitcoin.Features.MemoryPool
replacementOptOut
=
false
;
break
;
}
}
if
(
replacementOptOut
)
context
.
State
.
Invalid
(
MempoolErrors
.
Conflict
).
Throw
();
...
...
@@ -193,7 +199,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Validates the transaction fee is valid.
/// </summary>
/// <param name="context">Current validation context.</param>
p
rotected
override
void
CheckFee
(
MempoolValidationContext
context
)
p
ublic
override
void
CheckFee
(
MempoolValidationContext
context
)
{
long
expectedFee
=
Convert
.
ToInt64
(
context
.
Transaction
.
Outputs
.
Where
(
p
=>
!
context
.
Transaction
.
Inputs
.
RemoveChangePointer
()
...
...
@@ -201,7 +207,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
.
Concat
(
context
.
Transaction
.
Inputs
.
GetChangePointers
()
.
Select
(
q
=>
context
.
Transaction
.
Outputs
[
q
].
ScriptPubKey
))
.
Contains
(
p
.
ScriptPubKey
))
.
Sum
(
p
=>
p
.
Value
)
*
this
.
n
etwork
.
FeeRate
);
.
Sum
(
p
=>
p
.
Value
)
*
this
.
DeStreamN
etwork
.
FeeRate
);
if
(
context
.
ModifiedFees
<
expectedFee
)
context
.
State
.
Fail
(
MempoolErrors
.
InsufficientFee
,
$"
{
context
.
Fees
}
<
{
expectedFee
}
"
).
Throw
();
...
...
Sources/Stratis.Bitcoin.Features.MemoryPool/MemPoolCoinView.cs
View file @
30d9620f
...
...
@@ -19,10 +19,10 @@ namespace Stratis.Bitcoin.Features.MemoryPool
{
/// <summary>Transaction memory pool for managing transactions in the memory pool.</summary>
/// <remarks>All access to this object has to be protected by <see cref="mempoolLock"/>.</remarks>
pr
ivate
readonly
ITxMempool
memPool
;
pr
otected
readonly
ITxMempool
memPool
;
/// <summary>A lock for protecting access to <see cref="memPool"/>.</summary>
pr
ivate
readonly
SchedulerLock
mempoolLock
;
pr
otected
readonly
SchedulerLock
mempoolLock
;
/// <summary>Memory pool validator for validating transactions.</summary>
private
readonly
IMempoolValidator
mempoolValidator
;
...
...
@@ -46,7 +46,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// <summary>
/// Gets the unspent transaction output set.
/// </summary>
public
UnspentOutputSet
Set
{
get
;
pr
ivate
set
;
}
public
UnspentOutputSet
Set
{
get
;
pr
otected
set
;
}
/// <summary>
/// Backing coin view instance.
...
...
@@ -87,7 +87,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Load the coin view for a memory pool transaction.
/// </summary>
/// <param name="trx">Memory pool transaction.</param>
public
async
Task
LoadViewAsync
(
Transaction
trx
)
public
virtual
async
Task
LoadViewAsync
(
Transaction
trx
)
{
// lookup all ids (duplicate ids are ignored in case a trx spends outputs from the same parent).
List
<
uint256
>
ids
=
trx
.
Inputs
.
Select
(
n
=>
n
.
PrevOut
.
Hash
).
Distinct
().
Concat
(
new
[]
{
trx
.
GetHash
()
}).
ToList
();
...
...
Sources/Stratis.Bitcoin.Features.MemoryPool/MempoolManager.cs
View file @
30d9620f
...
...
@@ -32,10 +32,10 @@ namespace Stratis.Bitcoin.Features.MemoryPool
private
readonly
ILogger
logger
;
/// <summary>Transaction memory pool for managing transactions in the memory pool.</summary>
pr
ivate
readonly
ITxMempool
memPool
;
pr
otected
readonly
ITxMempool
memPool
;
/// <summary>Coin view of the memory pool.</summary>
pr
ivate
readonly
ICoinView
coinView
;
pr
otected
readonly
ICoinView
coinView
;
private
readonly
Network
network
;
...
...
@@ -217,7 +217,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
}
/// <inheritdoc />
public
async
Task
<
UnspentOutputs
>
GetUnspentTransactionAsync
(
uint256
trxid
)
public
virtual
async
Task
<
UnspentOutputs
>
GetUnspentTransactionAsync
(
uint256
trxid
)
{
TxMempoolInfo
txInfo
=
await
this
.
InfoAsync
(
trxid
);
if
(
txInfo
==
null
)
...
...
Sources/Stratis.Bitcoin.Features.MemoryPool/MempoolValidator.cs
View file @
30d9620f
...
...
@@ -114,28 +114,28 @@ namespace Stratis.Bitcoin.Features.MemoryPool
private
const
int
MaxFeeEstimationTipAge
=
3
*
60
*
60
;
/// <summary>A lock for managing asynchronous access to memory pool.</summary>
pr
ivate
readonly
MempoolSchedulerLock
mempoolLock
;
pr
otected
readonly
MempoolSchedulerLock
mempoolLock
;
/// <summary>Date and time information provider.</summary>
private
readonly
IDateTimeProvider
dateTimeProvider
;
/// <summary>Settings from the memory pool.</summary>
pr
ivate
readonly
MempoolSettings
mempoolSettings
;
pr
otected
readonly
MempoolSettings
mempoolSettings
;
/// <summary>Thread safe access to the best chain of block headers (that the node is aware of) from genesis.</summary>
private
readonly
ConcurrentChain
chain
;
/// <summary>Coin view of the memory pool.</summary>
pr
ivate
readonly
ICoinView
coinView
;
pr
otected
readonly
ICoinView
coinView
;
/// <inheritdoc cref="IConsensusRuleEngine" />
private
readonly
IConsensusRuleEngine
consensusRules
;
/// <summary>Transaction memory pool for managing transactions in the memory pool.</summary>
pr
ivate
readonly
ITxMempool
memPool
;
pr
otected
readonly
ITxMempool
memPool
;
/// <summary>Instance logger for memory pool validator.</summary>
pr
ivate
readonly
ILogger
logger
;
pr
otected
readonly
ILogger
logger
;
/// <summary>Minimum fee rate for a relay transaction.</summary>
private
readonly
FeeRate
minRelayTxFee
;
...
...
@@ -152,7 +152,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
// public long LastTime;
//}
pr
ivate
Network
network
;
pr
otected
Network
network
;
public
MempoolValidator
(
ITxMempool
memPool
,
...
...
@@ -413,7 +413,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// <param name="state">Validation state for creating the validation context.</param>
/// <param name="tx">The transaction to validate.</param>
/// <param name="vHashTxnToUncache">Not currently used</param>
pr
ivate
async
Task
AcceptToMemoryPoolWorkerAsync
(
MempoolValidationState
state
,
Transaction
tx
,
List
<
uint256
>
vHashTxnToUncache
)
pr
otected
virtual
async
Task
AcceptToMemoryPoolWorkerAsync
(
MempoolValidationState
state
,
Transaction
tx
,
List
<
uint256
>
vHashTxnToUncache
)
{
var
context
=
new
MempoolValidationContext
(
tx
,
state
);
...
...
@@ -491,7 +491,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// If a conflict is found it is added to the validation context.
/// </summary>
/// <param name="context">Current validation context.</param>
pr
ivate
void
CheckConflicts
(
MempoolValidationContext
context
)
pr
otected
virtual
void
CheckConflicts
(
MempoolValidationContext
context
)
{
context
.
SetConflicts
=
new
List
<
uint256
>();
foreach
(
TxIn
txin
in
context
.
Transaction
.
Inputs
)
...
...
@@ -691,7 +691,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Checks if already in coin view, and missing and unavailable inputs.
/// </summary>
/// <param name="context">Validation context.</param>
pr
ivate
void
CheckMempoolCoinView
(
MempoolValidationContext
context
)
pr
otected
virtual
void
CheckMempoolCoinView
(
MempoolValidationContext
context
)
{
Guard
.
Assert
(
context
.
View
!=
null
);
...
...
@@ -758,7 +758,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Check that the transaction doesn't have an excessive number of sigops.
/// </summary>
/// <param name="context">Current validation context.</param>
pr
ivate
void
CheckSigOps
(
MempoolValidationContext
context
)
pr
otected
void
CheckSigOps
(
MempoolValidationContext
context
)
{
// Check that the transaction doesn't have an excessive number of
// sigops, making it impossible to mine. Since the coinbase transaction
...
...
@@ -779,7 +779,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// </summary>
/// <param name="context">Current validation context.</param>
/// <param name="acceptTime">The accept time to use for the entry.</param>
pr
ivate
void
CreateMempoolEntry
(
MempoolValidationContext
context
,
long
acceptTime
)
pr
otected
void
CreateMempoolEntry
(
MempoolValidationContext
context
,
long
acceptTime
)
{
// Only accept BIP68 sequence locked transactions that can be mined in the next
// block; we don't want our mempool filled up with transactions that can't
...
...
@@ -838,7 +838,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// The new transaction must have sufficient fees to pay for it's bandwidth.
/// </summary>
/// <param name="context">Current validation context.</param>
pr
ivate
void
CheckReplacment
(
MempoolValidationContext
context
)
pr
otected
void
CheckReplacment
(
MempoolValidationContext
context
)
{
// Check if it's economically rational to mine this transaction rather
// than the ones it replaces.
...
...
@@ -969,7 +969,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// </summary>
/// <param name="context">Current validation context</param>
/// <param name="limitFree">Whether to limit free transactioins</param>
pr
ivate
void
CheckRateLimit
(
MempoolValidationContext
context
,
bool
limitFree
)
pr
otected
void
CheckRateLimit
(
MempoolValidationContext
context
,
bool
limitFree
)
{
// TODO: sort this logic
return
;
...
...
@@ -981,7 +981,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Checks for a transaction that spends outputs that would be replaced by it.
/// </summary>
/// <param name="context">Current validation context.</param>
pr
ivate
void
CheckAncestors
(
MempoolValidationContext
context
)
pr
otected
void
CheckAncestors
(
MempoolValidationContext
context
)
{
// Calculate in-mempool ancestors, up to a limit.
context
.
SetAncestors
=
new
TxMempool
.
SetEntries
();
...
...
@@ -1020,7 +1020,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// </summary>
/// <param name="limit">New size.</param>
/// <param name="age">AAge to use for calculating expired transactions.</param>
pr
ivate
void
LimitMempoolSize
(
long
limit
,
long
age
)
pr
otected
void
LimitMempoolSize
(
long
limit
,
long
age
)
{
int
expired
=
this
.
memPool
.
Expire
(
this
.
dateTimeProvider
.
GetTime
()
-
age
);
if
(
expired
!=
0
)
...
...
@@ -1035,7 +1035,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// It should only count for fee estimation if the node is not behind.
/// </summary>
/// <returns>Whether current for fee estimation.</returns>
pr
ivate
bool
IsCurrentForFeeEstimation
()
pr
otected
bool
IsCurrentForFeeEstimation
()
{
// TODO: implement method (find a way to know if in IBD)
...
...
@@ -1058,7 +1058,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// Checks against <see cref="ScriptVerify.Standard"/> and <see cref="ScriptVerify.P2SH"/>
/// </summary>
/// <param name="context">Current validation context.</param>
pr
ivate
void
CheckAllInputs
(
MempoolValidationContext
context
)
pr
otected
void
CheckAllInputs
(
MempoolValidationContext
context
)
{
var
scriptVerifyFlags
=
ScriptVerify
.
Standard
;
if
(!
this
.
mempoolSettings
.
RequireStandard
)
...
...
@@ -1177,7 +1177,7 @@ namespace Stratis.Bitcoin.Features.MemoryPool
/// <param name="tx">Transaction to verify.</param>
/// <param name="mapInputs">Map of previous transactions that have outputs we're spending.</param>
/// <returns>Whether all inputs (scriptSigs) use only standard transaction forms.</returns>
pr
ivate
bool
AreInputsStandard
(
Transaction
tx
,
MempoolCoinView
mapInputs
)
pr
otected
virtual
bool
AreInputsStandard
(
Transaction
tx
,
MempoolCoinView
mapInputs
)
{
if
(
tx
.
IsCoinBase
)
{
...
...
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