Show / Hide Table of Contents

Class BlockMetadataExtensions

Convenient extension methods for IBlockMetadata.

Inheritance
Object
BlockMetadataExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Blocks
Assembly: Libplanet.dll
Syntax
public static class BlockMetadataExtensions

Methods

| Improve this Doc View Source

Copy(IBlockMetadata)

Creates a BlockMetadata by copying the fields of another block metadata.

This is a shortcut of BlockMetadata(IBlockMetadata) constructor.

Declaration
public static BlockMetadata Copy(this IBlockMetadata metadata)
Parameters
Type Name Description
IBlockMetadata metadata

This source of the block metadata to copy. This hasn't be a actual BlockMetadata instance, but can be any object which implements IBlockMetadata instance.

Returns
Type Description
BlockMetadata

The copied block metadata.

Exceptions
Type Condition
InvalidBlockProtocolVersionException

Thrown when the metadata's to set is ProtocolVersion is less than 0, or greater than CurrentProtocolVersion, the latest known protocol version.

InvalidBlockIndexException

Thrown when the metadata has a negative Index.

InvalidBlockDifficultyException

Thrown when the metadata's Difficulty is negative.

InvalidBlockTotalDifficultyException

Thrown when the metadata's TotalDifficulty is less than its Difficulty.

See Also
BlockMetadata(IBlockMetadata)
| Improve this Doc View Source

ValidateTimestamp(IBlockMetadata)

Checks if the given blockMetadata's Timestamp is valid. No-op if valid.

Declaration
public static void ValidateTimestamp(this IBlockMetadata blockMetadata)
Parameters
Type Name Description
IBlockMetadata blockMetadata

The block metadata to validate.

Exceptions
Type Condition
InvalidBlockTimestampException

Thrown when Timestamp is invalid. For example, if Timestamp is too far in the future compared to the current time.

| Improve this Doc View Source

ValidateTimestamp(IBlockMetadata, DateTimeOffset)

Checks if the given blockMetadata's Timestamp is valid. No-op if valid.

Declaration
public static void ValidateTimestamp(this IBlockMetadata blockMetadata, DateTimeOffset currentTime)
Parameters
Type Name Description
IBlockMetadata blockMetadata

The block metadata to validate.

DateTimeOffset currentTime

Explicitly specify the current time.

Exceptions
Type Condition
InvalidBlockTimestampException

Thrown when Timestamp is invalid. For example, if Timestamp is too far in the future compared to currentTime.

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