github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/accounts/abi/numbers.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:26</date>
    10  //</624342583644000256>
    11  
    12  
    13  package abi
    14  
    15  import (
    16  	"math/big"
    17  	"reflect"
    18  
    19  	"github.com/ethereum/go-ethereum/common"
    20  	"github.com/ethereum/go-ethereum/common/math"
    21  )
    22  
    23  var (
    24  	bigT      = reflect.TypeOf(&big.Int{})
    25  	derefbigT = reflect.TypeOf(big.Int{})
    26  	uint8T    = reflect.TypeOf(uint8(0))
    27  	uint16T   = reflect.TypeOf(uint16(0))
    28  	uint32T   = reflect.TypeOf(uint32(0))
    29  	uint64T   = reflect.TypeOf(uint64(0))
    30  	int8T     = reflect.TypeOf(int8(0))
    31  	int16T    = reflect.TypeOf(int16(0))
    32  	int32T    = reflect.TypeOf(int32(0))
    33  	int64T    = reflect.TypeOf(int64(0))
    34  	addressT  = reflect.TypeOf(common.Address{})
    35  )
    36  
    37  //u256将一个大整数转换为256bit evm数。
    38  func U256(n *big.Int) []byte {
    39  	return math.PaddedBigBytes(math.U256(n), 32)
    40  }
    41