powerplay

package
v0.0.0-...-75aef46 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockInterval uint64 = 10 // time interval between two consecutive blocks.

	TxGas                     uint64 = 5000
	ClauseGas                 uint64 = params.TxGas - TxGas
	ClauseGasContractCreation uint64 = params.TxGasContractCreation - TxGas

	MinGasLimit          uint64 = 1000 * 1000
	InitialGasLimit      uint64 = 10 * 1000 * 1000 // InitialGasLimit gas limit value int genesis block.
	GasLimitBoundDivisor uint64 = 1024             // from ethereum
	GetBalanceGas        uint64 = 400              //EIP158 gas table
	SloadGas             uint64 = 200              // EIP158 gas table
	SstoreSetGas         uint64 = params.SstoreSetGas
	SstoreResetGas       uint64 = params.SstoreResetGas

	MaxTxWorkDelay uint32 = 30 // (unit: block) if tx delay exceeds this value, no energy can be exchanged.

	MaxBlockProposers uint64 = 101

	TolerableBlockPackingTime = 2 * time.Second // the indicator to adjust target block gas limit

	MaxBackTrackingBlockNumber = 65535
)

Constants of block chain.

View Source
const (
	// AddressLength length of address in bytes.
	AddressLength = common.AddressLength
)

Variables

View Source
var (
	KeyExecutorAddress     = BytesToBytes32([]byte("executor"))
	KeyRewardRatio         = BytesToBytes32([]byte("reward-ratio"))
	KeyBaseGasPrice        = BytesToBytes32([]byte("base-gas-price"))
	KeyProposerEndorsement = BytesToBytes32([]byte("proposer-endorsement"))

	InitialRewardRatio         = big.NewInt(3e17) // 30%
	InitialBaseGasPrice        = big.NewInt(1e15)
	InitialProposerEndorsement = new(big.Int).Mul(big.NewInt(1e18), big.NewInt(25000000))

	EnergyGrowthRate = big.NewInt(5000000000) // WEI POWERPLAY per token(PMK) per second. about 0.000325 POWERPLAY per token per day.
)

Keys of governance params.

View Source
var NoFork = ForkConfig{
	FixTransferLog: math.MaxUint32,
}

NoFork a special config without any forks.

Functions

func EstimateBloomK

func EstimateBloomK(itemCount int) int

EstimateBloomK estimate k(num of hash funcs) according to item count.

func NewBlake2b

func NewBlake2b() hash.Hash

NewBlake2b return blake2b-256 hash.

Types

type Address

type Address common.Address

Address address of account.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress converts bytes slice into address. If b is larger than address legnth, b will be cropped (from the left). If b is smaller than address length, b will be extended (from the left).

func CreateContractAddress

func CreateContractAddress(txID Bytes32, clauseIndex uint32, creationCount uint32) Address

CreateContractAddress to generate contract address according to tx id, clause index and contract creation count.

func MustParseAddress

func MustParseAddress(s string) Address

MustParseAddress convert string presented address into Address type, panic on error.

func ParseAddress

func ParseAddress(s string) (Address, error)

ParseAddress convert string presented address into Address type.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns byte slice form of address.

func (Address) IsZero

func (a Address) IsZero() bool

IsZero returns if address is all zero bytes.

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Address) String

func (a Address) String() string

String implements the stringer interface

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Bloom

type Bloom struct {
	Bits [bitsLength / 8]byte
	K    int
}

Bloom a simple bloom filter in 2048 bit length.

func NewBloom

func NewBloom(k int) *Bloom

NewBloom new bloom.

func (*Bloom) Add

func (b *Bloom) Add(item []byte)

Add add item into bloom.

func (*Bloom) Test

func (b *Bloom) Test(item []byte) bool

Test test if item contained. (false positive)

type Bytes32

type Bytes32 [32]byte

Bytes32 array of 32 bytes.

func Blake2b

func Blake2b(data ...[]byte) (b32 Bytes32)

Blake2b computes blake2b-256 checksum for given data.

func BytesToBytes32

func BytesToBytes32(b []byte) Bytes32

BytesToBytes32 converts bytes slice into Bytes32. If b is larger than Bytes32 legnth, b will be cropped (from the left). If b is smaller than Bytes32 length, b will be extended (from the left).

func MustParseBytes32

func MustParseBytes32(s string) Bytes32

MustParseBytes32 convert string presented into Bytes32 type, panic on error.

func ParseBytes32

func ParseBytes32(s string) (Bytes32, error)

ParseBytes32 convert string presented into Bytes32 type

func (Bytes32) AbbrevString

func (b Bytes32) AbbrevString() string

AbbrevString returns abbrev string presentation.

func (Bytes32) Bytes

func (b Bytes32) Bytes() []byte

Bytes returns byte slice form of Bytes32.

func (Bytes32) IsZero

func (b Bytes32) IsZero() bool

IsZero returns if Bytes32 has all zero bytes.

func (*Bytes32) MarshalJSON

func (b *Bytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Bytes32) String

func (b Bytes32) String() string

String implements stringer

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ForkConfig

type ForkConfig struct {
	FixTransferLog uint32
}

ForkConfig config for a fork.

func GetForkConfig

func GetForkConfig(genesisID Bytes32) ForkConfig

GetForkConfig get fork config for given genesis ID.

func (ForkConfig) String

func (fc ForkConfig) String() string

Jump to

Keyboard shortcuts

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