/// <summary>The minimum amount of blocks that can be stored in Pending Storage before they get processed.</summary>
publicconstintPendingStorageBatchThreshold=10;
/// <summary>The chain of steps that gets executed to find and download blocks.</summary>
privateBlockStoreStepChainstepChain;
/// <summary>Cached consensus tip.</summary>
/// <remarks>
/// Cached tip is needed in order to avoid race condition in the <see cref="DownloadAndStoreBlocksAsync"/>.
/// <para>
/// This condition happens when the actual ConsensusTip is updated but the block wasn't provided by signaler yet.
/// </para>
/// <para>
/// TODO: remove this quick fix later and solve the race condition by replacing the async loop with trigger-based invoking of <see cref="DownloadAndStoreBlocksAsync"/>.
/// </para>
/// </remarks>
privateChainedHeaderCachedConsensusTip;
publicvirtualstringStoreName
{
get{return"BlockStore";}
}
privatereadonlyStoreSettingsstoreSettings;
/// <summary>The highest stored block in the repository.</summary>
internalChainedHeaderStoreTip{get;privateset;}
/// <summary>Public constructor for unit testing.</summary>
/// The <see cref="BlockStoreSignaled"/> calls this method when a new block is available. Only add the block to pending storage if the store's tip is behind the given block.
/// </para>
/// </summary>
/// <param name="blockPair">The block and its chained header pair to be added to pending storage.</param>
/// <remarks>TODO: Possibly check the size of pending in memory</remarks>
/// Context for the inner steps, <see cref="BlockStoreInnerStepFindBlocks"/> and <see cref="BlockStoreInnerStepReadBlocks"/>.
/// <para>
/// The context also initializes the inner step <see cref="InnerSteps"/>.
/// </para>
/// </summary>
publicsealedclassBlockStoreInnerStepContext
{
/// <summary>Number of milliseconds to wait after each failed attempt to get a block from the block puller.</summary>
internalconstintStallDelayMs=100;
/// <summary><see cref="DownloadStack"/> is flushed to the disk if more than this amount of milliseconds passed since the last flush was made.</summary>
this.logger.LogDebug("Serialized size is {0} bytes, block weight is {1}, number of txs is {2}, tx fees are {3}, number of sigops is {4}.",nSerializeSize,this.ConsensusLoop.Validator.GetBlockWeight(this.block),this.BlockTx,this.fees,this.BlockSigOpsCost);