util

package
v0.0.0-...-c3c44a6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php

Index

Constants

View Source
const (
	RewardFullRate = uint64(10000)
	Stop           = "0"
	TxsReward      = 0
	BlkReward      = 1
)
View Source
const (
	PackageName = "奖励util"
)

Variables

View Source
var (
	//ValidatorBlockReward  *big.Int = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), big.NewInt(0)) // Block reward in wei for successfully mining a block
	MultilCoinBlockReward *big.Int = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), big.NewInt(0)) // Block reward in wei for successfully mining a block upward from Byzantium
	//分母10000
	ByzantiumTxsRewardDen *big.Int = big.NewInt(1000000000) // Block reward in wei for successfully mining a block upward from Byzantium
	ValidatorsBlockReward *big.Int = big.NewInt(5e+18)
	MinersBlockReward     *big.Int = big.NewInt(5e+18)

	ManPrice *big.Int = big.NewInt(1e18)

	ThousandthManPrice *big.Int = big.NewInt(1e15)

	Precision *big.Int = big.NewInt(1)
	CalcAlpha          = "1"
	CalcGamma          = "2"
	CalcDelta          = "3"
)

Functions

func AccumulatorCheck

func AccumulatorCheck(st StateDB, rewardIn []common.RewarTx) []common.RewarTx

func CalcInterestReward

func CalcInterestReward(reward *big.Int, interest map[common.Address]*big.Int) map[common.Address]*big.Int

func CalcN

func CalcN(halfNum uint64, num uint64) uint64

func CalcRateReward

func CalcRateReward(rewardAmount *big.Int, rate uint64) *big.Int

func CalcRewardMount

func CalcRewardMount(blockReward *big.Int, n uint64, x uint16) *big.Int

func CalcRewardMountByNumber

func CalcRewardMountByNumber(st StateDB, blockReward *big.Int, num uint64, halfNum uint64, address common.Address, attenuationRate uint16) *big.Int

func CalcStockRate

func CalcStockRate(reward *big.Int, depositNodes map[common.Address]DepositInfo) map[common.Address]*big.Int

func CointypeCheck

func CointypeCheck(st StateDB, rewardIn []common.RewarTx) []common.RewarTx

func GetPreMinerReward

func GetPreMinerReward(state StateDB, rewardType uint8) ([]mc.MultiCoinMinerOutReward, error)

func GetPrice

func GetPrice(calc string) *big.Int

func LogExtraDebug

func LogExtraDebug(msg string, ctx ...interface{})

func MergeReward

func MergeReward(dst map[common.Address]*big.Int, src map[common.Address]*big.Int)

func PrintLog2File

func PrintLog2File(filename string, data interface{})

func SetAccountRewards

func SetAccountRewards(rewards map[common.Address]*big.Int, account common.Address, reward *big.Int)

func SetExtralevel

func SetExtralevel(level uint8)

func SetLoglevel

func SetLoglevel(level uint8)

Types

type ChainReader

type ChainReader interface {

	// GetHeaderByHash retrieves a block header from the database by its hash.
	GetHeaderByHash(hash common.Hash) *types.Header

	// GetBlock retrieves a block sfrom the database by hash and number.
	StateAt(root []common.CoinRoot) (*state.StateDBManage, error)
	State() (*state.StateDBManage, error)
	GetGraphByState(state matrixstate.StateDB) (*mc.TopologyGraph, *mc.ElectGraph, error)
	StateAtBlockHash(hash common.Hash) (*state.StateDBManage, error)
	GetAncestorHash(sonHash common.Hash, ancestorNumber uint64) (common.Hash, error)
}

type DepositInfo

type DepositInfo struct {
	Deposit  *big.Int
	FixStock uint64
}

type StateDB

type StateDB interface {
	GetBalance(typ string, addr common.Address) common.BalanceType
	GetMatrixData(hash common.Hash) (val []byte)
	SetMatrixData(hash common.Hash, val []byte)
}

Jump to

Keyboard shortcuts

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