Class TotalDifficultyComparer
The default canonical chain comparer (which purpose to be a CanonicalChainComparer).
The chain which has the most TotalDifficulty is considered the greatest, i.e., canonical chain.
Implements
Inherited Members
Namespace: Libplanet.Blockchain
Assembly: Libplanet.dll
Syntax
public class TotalDifficultyComparer : IComparer<BlockPerception>
Remarks
Although this compares blocks' total difficulty, if two blocks have different protocol version, it always consider the higher version greater.
Constructors
| Improve this Doc View SourceTotalDifficultyComparer(TimeSpan)
Creates a TotalDifficultyComparer instance.
Declaration
public TotalDifficultyComparer(TimeSpan outdateAfter)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | outdateAfter | Blocks taken this time since they are perceived are considered outdated, so that chains having these blocks as their tips become stale. |
TotalDifficultyComparer(TimeSpan, Func<DateTimeOffset>)
Creates a TotalDifficultyComparer instance.
Declaration
public TotalDifficultyComparer(TimeSpan outdateAfter, Func<DateTimeOffset> currentTimeGetter)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | outdateAfter | Blocks taken this time since they are perceived are considered outdated, so that chains having these blocks as their tips become stale. |
Func<DateTimeOffset> | currentTimeGetter | Configures the way to get the current time instead of UtcNow property. |
Properties
| Improve this Doc View SourceOutdateAfter
Blocks taken this time since they are perceived are considered outdated, so that chains having these blocks as their tips become stale.
Declaration
public TimeSpan OutdateAfter { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Improve this Doc View SourceCompare(BlockPerception, BlockPerception)
Declaration
public int Compare(BlockPerception x, BlockPerception y)
Parameters
Type | Name | Description |
---|---|---|
BlockPerception | x | |
BlockPerception | y |
Returns
Type | Description |
---|---|
Int32 |