当前位置: 首页>>代码示例>>Golang>>正文


Golang Value.BigInt方法代码示例

本文整理汇总了Golang中github.com/ethereum/eth-go/ethutil.Value.BigInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.BigInt方法的具体用法?Golang Value.BigInt怎么用?Golang Value.BigInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ethereum/eth-go/ethutil.Value的用法示例。


在下文中一共展示了Value.BigInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExecuteObject

func (self *Pipe) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
	var (
		initiator   = ethstate.NewStateObject([]byte{0})
		block       = self.blockChain.CurrentBlock
		stateObject = object.StateObject
	)
	if self.Vm.State == nil {
		self.Vm.State = self.World().State().Copy()
	}

	vm := ethvm.New(NewEnv(self.Vm.State, block, value.BigInt(), initiator.Address()))

	closure := ethvm.NewClosure(&ethstate.Message{}, initiator, stateObject, object.Code, gas.BigInt(), price.BigInt())
	ret, _, err := closure.Call(vm, data)

	return ret, err
}
开发者ID:vmatekole,项目名称:eth-go,代码行数:17,代码来源:pipe.go

示例2: Transact

func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price *ethutil.Value, data []byte) ([]byte, error) {
	var hash []byte
	var contractCreation bool
	if rec == nil {
		contractCreation = true
	}

	var tx *ethchain.Transaction
	// Compile and assemble the given data
	if contractCreation {
		script, err := ethutil.Compile(string(data), false)
		if err != nil {
			return nil, err
		}

		tx = ethchain.NewContractCreationTx(value.BigInt(), gas.BigInt(), price.BigInt(), script)
	} else {
		data := ethutil.StringToByteFunc(string(data), func(s string) (ret []byte) {
			slice := strings.Split(s, "\n")
			for _, dataItem := range slice {
				d := ethutil.FormatData(dataItem)
				ret = append(ret, d...)
			}
			return
		})

		tx = ethchain.NewTransactionMessage(hash, value.BigInt(), gas.BigInt(), price.BigInt(), data)
	}

	acc := self.stateManager.TransState().GetOrNewStateObject(key.Address())
	tx.Nonce = acc.Nonce
	acc.Nonce += 1
	self.stateManager.TransState().UpdateStateObject(acc)

	tx.Sign(key.PrivateKey)
	self.obj.TxPool().QueueTransaction(tx)

	if contractCreation {
		logger.Infof("Contract addr %x", tx.CreationAddress())

		return tx.CreationAddress(), nil
	}

	return tx.Hash(), nil
}
开发者ID:vmatekole,项目名称:eth-go,代码行数:45,代码来源:pipe.go


注:本文中的github.com/ethereum/eth-go/ethutil.Value.BigInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。