consensus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// define the Max transaction size and Max block size
	MaxTxSize    = uint64(1048576)
	MaxBlockSzie = uint64(1048576)

	//config parameter for coinbase reward
	CoinbasePendingBlockNumber = uint64(6)

	BlocksPerRetarget = uint64(1024)
)

consensus variables

Variables

View Source
var BTMAssetID = &bc.AssetID{
	V0: uint64(18446744073709551615),
	V1: uint64(18446744073709551615),
	V2: uint64(18446744073709551615),
	V3: uint64(18446744073709551615),
}

BTMAssetID is BTM's asset id, the soul asset of Bytom

View Source
var MainNetParams = Params{
	Name:            "main",
	Bech32HRPSegwit: "bm",
}

MainNetParams is the config for production

View Source
var TestNetParams = Params{
	Name:            "test",
	Bech32HRPSegwit: "tm",
}

TestNetParams is the config for test-net

Functions

func BigToCompact

func BigToCompact(n *big.Int) uint64

BigToCompact converts a whole number N to a compact representation using an unsigned 64-bit number

func BlockSubsidy

func BlockSubsidy(height uint64) uint64

BlockSubsidy calculate the coinbase rewards on given block height

func CalcNextRequiredDifficulty

func CalcNextRequiredDifficulty(lastBH, compareBH *legacy.BlockHeader) uint64

func CheckProofOfWork

func CheckProofOfWork(hash *bc.Hash, bits uint64) bool

func CompactToBig

func CompactToBig(compact uint64) *big.Int

CompactToBig converts a compact representation of a whole number N to an unsigned 64-bit number. The representation is similar to IEEE754 floating point numbers.

-------------------------------------------------
|   Exponent     |    Sign    |    Mantissa     |
-------------------------------------------------
| 8 bits [63-56] | 1 bit [55] | 55 bits [54-00] |
-------------------------------------------------

N = (-1^sign) * mantissa * 256^(exponent-3)

func HashToBig

func HashToBig(hash *bc.Hash) *big.Int

perform math comparisons.

func IsBech32SegwitPrefix added in v0.1.4

func IsBech32SegwitPrefix(prefix string, params *Params) bool

IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit addresses on any default or registered network. This is used when decoding an address string into a specific address type.

Types

type Params added in v0.1.4

type Params struct {
	// Name defines a human-readable identifier for the network.
	Name            string
	Bech32HRPSegwit string
}

Params store the config for different network

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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