Equity
Bitcoin Protocol Library
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Equity::Target Class Reference

Represents a target value in both 256-bit hash form and compact form. More...

#include <Target.h>

Public Member Functions

 Target (Crypto::Sha256Hash const &hash)
 
 Target (uint32_t compact)
 
 operator Crypto::Sha256Hash () const
 Returns the hash form.
 
 operator uint32_t () const
 Returns the compact form.
 
double difficulty () const
 Returns the associated difficulty value.
 

Static Public Member Functions

static Crypto::Sha256Hash convertToHash (uint32_t compact)
 Computes the hash form based on the compact form.
 
static uint32_t convertToCompact (Crypto::Sha256Hash const &hash)
 Computes the compact form based on the hash form.
 

Static Public Attributes

static uint32_t const DIFFICULTY_1_COMPACT = 0x1d00ffff
 Target in compact form of difficulty 1.
 
static Crypto::Sha256Hash const DIFFICULTY_1
 Target in hash form of difficulty 1. More...
 
static uint32_t const TARGET_0_COMPACT = 0x0100ffff
 Target value of 0 in compact form.
 

Detailed Description

Represents a target value in both 256-bit hash form and compact form.

31 0 Format of the compact form: eeeeeeeesmmmmmmmmmmmmmmmmmmmmmmm

e is an 8-bit exponent (0 <= e <= 0x1d), s is a sign bit and m is a 23-bit unsigned mantissa (0 <= m <= 0x7fffff). The value represented by the compact form is m * 256^(e-3). Note that since the target value is always positive, s is always 0.

Constructor & Destructor Documentation

Target::Target ( Crypto::Sha256Hash const &  hash)
explicit
Parameters
hashtarget in hash form
Target::Target ( uint32_t  compact)
explicit
Parameters
compacttarget in compact form

Member Data Documentation

Crypto::Sha256Hash const Target::DIFFICULTY_1
static
Initial value:
=
{
{
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
}

Target in hash form of difficulty 1.


The documentation for this class was generated from the following files: