Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
f30b809f
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f30b809f
编写于
3月 01, 2016
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2215 from bas-vk/estimategas
core: improved check for contract creation
上级
7d598af4
0ff2adb2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
35 deletion
+32
-35
core/state_transition.go
core/state_transition.go
+1
-1
eth/api.go
eth/api.go
+31
-34
未找到文件。
core/state_transition.go
浏览文件 @
f30b809f
...
...
@@ -78,7 +78,7 @@ func MessageCreatesContract(msg Message) bool {
return
msg
.
To
()
==
nil
}
// IntrinsicGas computes the 'intrisic gas' for a message
// IntrinsicGas computes the 'intri
n
sic gas' for a message
// with the given data.
func
IntrinsicGas
(
data
[]
byte
,
contractCreation
,
homestead
bool
)
*
big
.
Int
{
igas
:=
new
(
big
.
Int
)
...
...
eth/api.go
浏览文件 @
f30b809f
...
...
@@ -620,12 +620,12 @@ func (m callmsg) Value() *big.Int { return m.value }
func
(
m
callmsg
)
Data
()
[]
byte
{
return
m
.
data
}
type
CallArgs
struct
{
From
common
.
Address
`json:"from"`
To
common
.
Address
`json:"to"`
Gas
rpc
.
HexNumber
`json:"gas"`
GasPrice
rpc
.
HexNumber
`json:"gasPrice"`
Value
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
From
common
.
Address
`json:"from"`
To
*
common
.
Address
`json:"to"`
Gas
rpc
.
HexNumber
`json:"gas"`
GasPrice
rpc
.
HexNumber
`json:"gasPrice"`
Value
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
}
func
(
s
*
PublicBlockChainAPI
)
doCall
(
args
CallArgs
,
blockNr
rpc
.
BlockNumber
)
(
string
,
*
big
.
Int
,
error
)
{
...
...
@@ -653,7 +653,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
// Assemble the CALL invocation
msg
:=
callmsg
{
from
:
from
,
to
:
&
args
.
To
,
to
:
args
.
To
,
gas
:
args
.
Gas
.
BigInt
(),
gasPrice
:
args
.
GasPrice
.
BigInt
(),
value
:
args
.
Value
.
BigInt
(),
...
...
@@ -665,6 +665,7 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
if
msg
.
gasPrice
.
Cmp
(
common
.
Big0
)
==
0
{
msg
.
gasPrice
=
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
}
// Execute the call and return
vmenv
:=
core
.
NewEnv
(
stateDb
,
s
.
bc
,
msg
,
block
.
Header
())
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
common
.
MaxBig
)
...
...
@@ -1012,13 +1013,13 @@ func (s *PublicTransactionPoolAPI) sign(address common.Address, tx *types.Transa
}
type
SendTxArgs
struct
{
From
common
.
Address
`json:"from"`
To
common
.
Address
`json:"to"`
Gas
*
rpc
.
HexNumber
`json:"gas"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
Value
*
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
From
common
.
Address
`json:"from"`
To
*
common
.
Address
`json:"to"`
Gas
*
rpc
.
HexNumber
`json:"gas"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
Value
*
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
}
// SendTransaction will create a transaction for the given transaction argument, sign it and submit it to the
...
...
@@ -1042,12 +1043,12 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash
}
var
tx
*
types
.
Transaction
contractCreation
:=
(
args
.
To
==
common
.
Address
{}
)
contractCreation
:=
(
args
.
To
==
nil
)
if
contractCreation
{
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
else
{
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
*
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
...
...
@@ -1106,7 +1107,7 @@ func (s *PublicTransactionPoolAPI) Sign(address common.Address, data string) (st
type
SignTransactionArgs
struct
{
From
common
.
Address
To
common
.
Address
To
*
common
.
Address
Nonce
*
rpc
.
HexNumber
Value
*
rpc
.
HexNumber
Gas
*
rpc
.
HexNumber
...
...
@@ -1132,23 +1133,21 @@ type Tx struct {
func
(
tx
*
Tx
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
req
:=
struct
{
To
common
.
Address
`json:"to"`
From
common
.
Address
`json:"from"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
Value
*
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
GasLimit
*
rpc
.
HexNumber
`json:"gas"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
Hash
common
.
Hash
`json:"hash"`
To
*
common
.
Address
`json:"to"`
From
common
.
Address
`json:"from"`
Nonce
*
rpc
.
HexNumber
`json:"nonce"`
Value
*
rpc
.
HexNumber
`json:"value"`
Data
string
`json:"data"`
GasLimit
*
rpc
.
HexNumber
`json:"gas"`
GasPrice
*
rpc
.
HexNumber
`json:"gasPrice"`
Hash
common
.
Hash
`json:"hash"`
}{}
if
err
:=
json
.
Unmarshal
(
b
,
&
req
);
err
!=
nil
{
return
err
}
contractCreation
:=
(
req
.
To
==
(
common
.
Address
{}))
tx
.
To
=
&
req
.
To
tx
.
To
=
req
.
To
tx
.
From
=
req
.
From
tx
.
Nonce
=
req
.
Nonce
tx
.
Value
=
req
.
Value
...
...
@@ -1172,12 +1171,10 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
tx
.
GasPrice
=
rpc
.
NewHexNumber
(
int64
(
50000000000
))
}
contractCreation
:=
(
req
.
To
==
nil
)
if
contractCreation
{
tx
.
tx
=
types
.
NewContractCreation
(
tx
.
Nonce
.
Uint64
(),
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
}
else
{
if
tx
.
To
==
nil
{
return
fmt
.
Errorf
(
"need to address"
)
}
tx
.
tx
=
types
.
NewTransaction
(
tx
.
Nonce
.
Uint64
(),
*
tx
.
To
,
tx
.
Value
.
BigInt
(),
tx
.
GasLimit
.
BigInt
(),
tx
.
GasPrice
.
BigInt
(),
data
)
}
...
...
@@ -1226,12 +1223,12 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (*
}
var
tx
*
types
.
Transaction
contractCreation
:=
(
args
.
To
==
common
.
Address
{}
)
contractCreation
:=
(
args
.
To
==
nil
)
if
contractCreation
{
tx
=
types
.
NewContractCreation
(
args
.
Nonce
.
Uint64
(),
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
else
{
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
tx
=
types
.
NewTransaction
(
args
.
Nonce
.
Uint64
(),
*
args
.
To
,
args
.
Value
.
BigInt
(),
args
.
Gas
.
BigInt
(),
args
.
GasPrice
.
BigInt
(),
common
.
FromHex
(
args
.
Data
))
}
signedTx
,
err
:=
s
.
sign
(
args
.
From
,
tx
)
...
...
@@ -1324,7 +1321,7 @@ func (s *PublicTransactionPoolAPI) Resend(tx *Tx, gasPrice, gasLimit *rpc.HexNum
}
var
newTx
*
types
.
Transaction
contractCreation
:=
(
*
tx
.
tx
.
To
()
==
common
.
Address
{}
)
contractCreation
:=
(
tx
.
tx
.
To
()
==
nil
)
if
contractCreation
{
newTx
=
types
.
NewContractCreation
(
tx
.
tx
.
Nonce
(),
tx
.
tx
.
Value
(),
gasPrice
.
BigInt
(),
gasLimit
.
BigInt
(),
tx
.
tx
.
Data
())
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录