difficulty

package
v0.0.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTargetHex

func GetTargetHex(diff int64) string

GetTargetHex 将难度值转换为目标值的十六进制字符串

func GetTargetHexByScrypt

func GetTargetHexByScrypt(diff int64) string

GetTargetHexByScrypt 将难度值转换为目标值的十六进制字符串(莱特币Scrypt 算法类)

func GetTargetHexBySha256d

func GetTargetHexBySha256d(diff int64) string

GetTargetHexBySha256d 将难度值转换为目标值的十六进制字符串(比特币 Sha256d 算法)

func HexDifficultyToDifficulty

func HexDifficultyToDifficulty(hexDifficulty string) map[string]*Difficulty

func NewDifficultyMap

func NewDifficultyMap(diffNumber int64) map[string]*Difficulty

func TargetHexToDiff

func TargetHexToDiff(diffHexStr string) *big.Int

TargetHexToDiff 将目标值的十六进制字符串转换为难度值

func TargetHexToDiffByScrypt

func TargetHexToDiffByScrypt(diffHexStr string) *big.Int

TargetHexToDiffByScrypt 将目标值的十六进制字符串转换为难度值(莱特币Scrypt 算法类)

func TargetHexToDiffBySha256d

func TargetHexToDiffBySha256d(diffHexStr string) *big.Int

TargetHexToDiffBySha256d 将目标值的十六进制字符串转换为难度值(比特币 Sha256d 算法)

Types

type DiffUnit

type DiffUnit string

DiffUnit 格式显示

const (
	DiffUnitNone  DiffUnit = "none"  // default none 未知,默认:无单位或基础单位
	DiffUnitKilo  DiffUnit = "Kilo"  // Kilo 千
	DiffUnitMega  DiffUnit = "Mega"  // Mega 兆
	DiffUnitGiga  DiffUnit = "Giga"  // Giga 吉
	DiffUnitTera  DiffUnit = "Tera"  // Tera 太
	DiffUnitPeta  DiffUnit = "Peta"  // Peta 拍
	DiffUnitExa   DiffUnit = "Exa"   // Exa 艾
	DiffUnitZetta DiffUnit = "Zetta" // Zetta 泽
	DiffUnitYotta DiffUnit = "Yotta" // Yotta 尧
)

func (DiffUnit) Shortname

func (aType DiffUnit) Shortname() string

Shortname 获取简写

type DiffUnitFormatType

type DiffUnitFormatType int
const (
	DiffUnitFormatType1000 DiffUnitFormatType = 1000
	DiffUnitFormatType1024 DiffUnitFormatType = 1024
)

type Difficulty

type Difficulty struct {
	Algorithm                     string
	Difficulty                    *big.Int
	DifficultyStringShort         string
	DifficultyStringShortFull     string
	DifficultyStringShort1024     string
	DifficultyStringShortFull1024 string
	DifficultyUnitShort           string
	DifficultyHexString           string
	DifficultyUnit                DiffUnit
	DifficultyUnitExtendStr       string     // 扩展拼接字段
	DifficultyValue               *big.Float // 存储计算后的难度值
}

Difficulty 难度结构体

func (*Difficulty) CalculateSpecificDifficulty

func (diff *Difficulty) CalculateSpecificDifficulty()

func (*Difficulty) FormatUnit

func (diff *Difficulty) FormatUnit(fSed int)

FormatUnit 单位计算公式 以 byte 为单位传入,根据数值不同换算成进制单位MB、GB等 fSed 小数点保留位数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL