Show / Hide Table of Contents

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.

Inheritance
Object
TotalDifficultyComparer
Implements
IComparer<BlockPerception>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
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 Source

TotalDifficultyComparer(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.

| Improve this Doc View Source

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 Source

OutdateAfter

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 Source

Compare(BlockPerception, BlockPerception)

Declaration
public int Compare(BlockPerception x, BlockPerception y)
Parameters
Type Name Description
BlockPerception x
BlockPerception y
Returns
Type Description
Int32

Implements

System.Collections.Generic.IComparer<T>

See Also

CanonicalChainComparer
IBlockExcerpt
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium