consensus

package
v0.0.0-...-5d360bc Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2017 License: MIT Imports: 7 Imported by: 0

README

共识算法 POW


POW算法:节点根据一定规则产生HASH数据,系统设置prefixToMatch,根据不同难度需求调整prefixToMatch

Documentation

Index

Constants

View Source
const Uint256IdxLen = 8 // The bigger it is, the more memory is needed, but lower chance of a collision

Variables

This section is empty.

Functions

func CheckProofOfWork

func CheckProofOfWork(prefixToMatch []byte, hash []byte) bool

CheckProofOfWork 确认POW是否匹配

func GetCompact

func GetCompact(b *big.Int) uint32

func GetDifficulty

func GetDifficulty(bits uint32) (diff float64)

func POWCheckProofOfWork

func POWCheckProofOfWork(hash *Uint256, bits uint32) bool

func Rimp160AfterSha256

func Rimp160AfterSha256(b []byte) (out [20]byte)

Returns hash: RIMP160( SHA256( data ) ) Where possible, using RimpHash() should be a bit faster

func RimpHash

func RimpHash(in []byte, out []byte)

func SetCompact

func SetCompact(nCompact uint32) (res *big.Int)

func Sha2Sum

func Sha2Sum(b []byte) (out [32]byte)

Returns hash: SHA256( SHA256( data ) ) Where possible, using ShaHash() should be a bit faster

func ShaHash

func ShaHash(b []byte, out []byte)

Types

type Uint256

type Uint256 struct {
	Hash [32]byte
}

func NewSha2Hash

func NewSha2Hash(data []byte) (res *Uint256)

func NewUint256

func NewUint256(h []byte) (res *Uint256)

func NewUint256FromString

func NewUint256FromString(s string) (res *Uint256)

Get from MSB hexstring

func (*Uint256) BIdx

func (u *Uint256) BIdx() (o [Uint256IdxLen]byte)

func (*Uint256) BigInt

func (u *Uint256) BigInt() *big.Int

func (*Uint256) Bytes

func (u *Uint256) Bytes() []byte

func (*Uint256) Equal

func (u *Uint256) Equal(o *Uint256) bool

func (*Uint256) String

func (u *Uint256) String() (s string)

Jump to

Keyboard shortcuts

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