difficulty

package
v0.0.0-...-fc8b1f8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 13 Imported by: 53

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LowestDifficultyCompact = uint32(4294967294) // Preset difficulty value before first adjustment of difficulty

)

Functions

func BigToHash

func BigToHash(currentHeight uint64, bignum *big.Int) []byte

func BigToHash256_v1

func BigToHash256_v1(bignum *big.Int) []byte

func BigToUint32_v1

func BigToUint32_v1(bignum *big.Int) uint32

func BitsToByte

func BitsToByte(bits []byte) byte

256 to 2

func BitsToBytes

func BitsToBytes(bits []byte) []byte

256 to 2

func ByteToBits

func ByteToBits(b byte) []byte

func BytesToBits

func BytesToBits(stuff []byte) []byte

256 to 2

func CalculateDifficultyWorthByHeight

func CalculateDifficultyWorthByHeight(blkhei uint64, diffnum uint32) *big.Int

func CalculateHashWorthByHeight

func CalculateHashWorthByHeight(blkhei uint64, hash []byte) *big.Int

func CalculateHashWorthForTest

func CalculateHashWorthForTest(hash []byte) *big.Int

func CalculateHashWorth_old

func CalculateHashWorth_old(hash []byte) *big.Int
func CalculateDifficultyWorth(diffnum uint32) *big.Int {
	diffhx := DifficultyUint32ToHashForAntimatter(diffnum)
	return CalculateHashWorthForTest(diffhx)
}
func CalculateDifficultyWorth_old_2022_9_9(diffnum uint32) *big.Int {
	diffhx := DifficultyUint32ToHashForAntimatter(diffnum)
	return CalculateHashWorthForTest(diffhx)
}
func CalculateDifficultyWorth_old_2022_02_08(diffnum uint32) *big.Int {
	diffhx := DifficultyUint32ToHashForAntimatter(diffnum)
	worth := DifficultyHashToBig(antimatterHash(diffhx))
	return worth
	//repeat := x16rs.HashRepeatForBlockHeight(curheight)
	//targetHashWorth := new(big.Int).Mul(worth, new(big.Int).SetUint64(uint64(repeat)))
	//return targetHashWorth
}

Calculate hash value

func CalculateHashWorth_old_2022_02_08

func CalculateHashWorth_old_2022_02_08(hash []byte) *big.Int

func CalculateHashWorth_old_2022_9_9

func CalculateHashWorth_old_2022_9_9(hash []byte) *big.Int

func CalculateNextDiffculty

func CalculateNextDiffculty(store interfaces.BlockStoreRead, lastestBlock interfaces.BlockHeadMetaRead) ([]byte, *big.Int, uint32, error)

func CalculateNextTarget

func CalculateNextTarget(
	lastestBits uint32,
	currentHeight uint64,
	prev288BlockTimestamp uint64,
	lastestTimestamp uint64,
	eachblocktime uint64,
	changeblocknum uint64,
	printInfo *string,
) ([]byte, *big.Int, uint32)

func CalculateNextTargetDifficulty_v1

func CalculateNextTargetDifficulty_v1(
	currentBits uint32,
	currentHeight uint64,
	prevTimestamp uint64,
	lastTimestamp uint64,
	eachblocktime uint64,
	changeblocknum uint64,
	printInfo *string,
) (*big.Int, uint32)

Calculate the block difficulty of the next stage

func CheckHashDifficultySatisfy

func CheckHashDifficultySatisfy(result_hash, target_diffculty_hash []byte) bool

func CheckHashDifficultySatisfyByBlock

func CheckHashDifficultySatisfyByBlock(blkhash []byte, block interfaces.Block) bool

func CheckHashDifficultySatisfyByDiffnum

func CheckHashDifficultySatisfyByDiffnum(blkhash []byte, blkhei uint64, diffnum uint32) bool

func ConvertHashToRate

func ConvertHashToRate(blkhei uint64, hx []byte, usetimesec int64) *big.Int

Convert to hash for calculation force display

func ConvertDifficultyToRateShow(diffnum uint32, usetimesec int64) string {
	hxworth := CalculateDifficultyWorth(diffnum)
	hashrate := new(big.Int).Div(hxworth, big.NewInt(usetimesec))
	hashrateshow := ConvertPowPowerToShowFormat(hashrate)
	return hashrateshow
}

Convert to hash for calculation force display

func ConvertHashToRateShow

func ConvertHashToRateShow(blkhei uint64, hx []byte, usetimesec int64) string

Convert to hash for calculation force display

func ConvertPowPowerToShowFormat

func ConvertPowPowerToShowFormat(value *big.Int) string

func ConvertPowPowerToShowFormat_old

func ConvertPowPowerToShowFormat_old(value *big.Int) string

func ConvertPowPowerToShowFormat_old2

func ConvertPowPowerToShowFormat_old2(value *big.Int) string

func DifficultyBigToHash

func DifficultyBigToHash(diff_big *big.Int) []byte

func DifficultyBigToUint32

func DifficultyBigToUint32(diff_big *big.Int) uint32

func DifficultyCalculateNextTarget_v2

func DifficultyCalculateNextTarget_v2(
	currentBits uint32,
	currentHeight uint64,
	prevTimestamp uint64,
	lastTimestamp uint64,
	eachblocktime uint64,
	changeblocknum uint64,
	printInfo *string,
) ([]byte, *big.Int, uint32)

Calculate the block difficulty of the next stage

func DifficultyHashToBig

func DifficultyHashToBig(hashbyte []byte) *big.Int

func DifficultyHashToUint32

func DifficultyHashToUint32(hash_byte []byte) uint32

func DifficultyUint32ToBig

func DifficultyUint32ToBig(diff_num uint32) *big.Int

func DifficultyUint32ToHash

func DifficultyUint32ToHash(diff_num uint32) []byte

func DifficultyUint32ToHashEx

func DifficultyUint32ToHashEx(diff_num uint32, filltail uint8) []byte

func DifficultyUint32ToHashForAntimatter

func DifficultyUint32ToHashForAntimatter(diff_num uint32) []byte

func Hash256ToUint32_v1

func Hash256ToUint32_v1(hash []byte) uint32

func HashToBig

func HashToBig(currentHeight uint64, hash []byte) *big.Int

func HashToBig_v1

func HashToBig_v1(hash []byte) *big.Int

func HashToUint32

func HashToUint32(currentHeight uint64, hash []byte) uint32

func ReadPrev288BlockTimestamp

func ReadPrev288BlockTimestamp(store interfaces.BlockStoreRead, blockHeight uint64) (uint64, error)

func Uint32ToBig

func Uint32ToBig(currentHeight uint64, diff_num uint32) *big.Int

func Uint32ToBig_v1

func Uint32ToBig_v1(number uint32) *big.Int

func Uint32ToHash

func Uint32ToHash(currentHeight uint64, diff_num uint32) []byte

func Uint32ToHash256_v1

func Uint32ToHash256_v1(number uint32) []byte

func Uint32ToHash_v1

func Uint32ToHash_v1(number uint32) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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