Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
c8a9a4e7
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,发现更多精彩内容 >>
提交
c8a9a4e7
编写于
5月 29, 2015
作者:
T
Taylor Gerring
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Differentiate between 0 and unspecified gas/gasprice
上级
0f1cdfa5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
36 deletion
+73
-36
rpc/api.go
rpc/api.go
+30
-2
rpc/args.go
rpc/args.go
+12
-12
rpc/args_test.go
rpc/args_test.go
+12
-8
xeth/xeth.go
xeth/xeth.go
+19
-14
未找到文件。
rpc/api.go
浏览文件 @
c8a9a4e7
...
...
@@ -182,7 +182,21 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
nonce
=
args
.
Nonce
.
String
()
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
nonce
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
var
gas
string
if
args
.
Gas
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
Gas
.
String
()
}
var
gasprice
string
if
args
.
GasPrice
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
GasPrice
.
String
()
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
nonce
,
args
.
Value
.
String
(),
gas
,
gasprice
,
args
.
Data
)
if
err
!=
nil
{
return
err
}
...
...
@@ -603,5 +617,19 @@ func (api *EthereumApi) doCall(params json.RawMessage) (string, string, error) {
return
""
,
""
,
err
}
return
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
var
gas
string
if
args
.
Gas
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
Gas
.
String
()
}
var
gasprice
string
if
args
.
GasPrice
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
GasPrice
.
String
()
}
return
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
gas
,
gasprice
,
args
.
Data
)
}
rpc/args.go
浏览文件 @
c8a9a4e7
...
...
@@ -261,22 +261,22 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Value
=
num
num
=
nil
if
ext
.
Gas
==
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
ext
.
Gas
!=
nil
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
return
err
}
}
else
{
num
=
nil
}
args
.
Gas
=
num
num
=
nil
if
ext
.
GasPrice
==
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
ext
.
GasPrice
!=
nil
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
return
err
}
}
else
{
num
=
nil
}
args
.
GasPrice
=
num
...
...
@@ -346,21 +346,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
}
args
.
Value
=
num
if
ext
.
Gas
==
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
ext
.
Gas
!=
nil
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
return
err
}
}
else
{
num
=
nil
}
args
.
Gas
=
num
if
ext
.
GasPrice
==
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
ext
.
GasPrice
!=
nil
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
return
err
}
}
else
{
num
=
nil
}
args
.
GasPrice
=
num
...
...
rpc/args_test.go
浏览文件 @
c8a9a4e7
...
...
@@ -573,14 +573,15 @@ func TestNewTxArgsGasMissing(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
expected
:=
new
(
NewTxArgs
)
expected
.
Gas
=
big
.
NewInt
(
0
)
expected
.
Gas
=
nil
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
bytes
.
Compare
(
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
!=
0
{
if
args
.
Gas
!=
expected
.
Gas
{
// if bytes.Compare(expected.Gas.Bytes(), args.Gas.Bytes()) != 0 {
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
}
}
...
...
@@ -594,14 +595,15 @@ func TestNewTxArgsBlockGaspriceMissing(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
expected
:=
new
(
NewTxArgs
)
expected
.
GasPrice
=
big
.
NewInt
(
0
)
expected
.
GasPrice
=
nil
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
bytes
.
Compare
(
expected
.
GasPrice
.
Bytes
(),
args
.
GasPrice
.
Bytes
())
!=
0
{
if
args
.
GasPrice
!=
expected
.
GasPrice
{
// if bytes.Compare(expected.GasPrice.Bytes(), args.GasPrice.Bytes()) != 0 {
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
}
...
...
@@ -829,9 +831,10 @@ func TestCallArgsGasMissing(t *testing.T) {
}
expected
:=
new
(
CallArgs
)
expected
.
Gas
=
big
.
NewInt
(
0
)
expected
.
Gas
=
nil
if
bytes
.
Compare
(
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
!=
0
{
if
args
.
Gas
!=
expected
.
Gas
{
// if bytes.Compare(expected.Gas.Bytes(), args.Gas.Bytes()) != 0 {
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
}
...
...
@@ -852,9 +855,10 @@ func TestCallArgsBlockGaspriceMissing(t *testing.T) {
}
expected
:=
new
(
CallArgs
)
expected
.
GasPrice
=
big
.
NewInt
(
0
)
expected
.
GasPrice
=
nil
if
bytes
.
Compare
(
expected
.
GasPrice
.
Bytes
(),
args
.
GasPrice
.
Bytes
())
!=
0
{
if
args
.
GasPrice
!=
expected
.
GasPrice
{
// if bytes.Compare(expected.GasPrice.Bytes(), args.GasPrice.Bytes()) != 0 {
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
}
}
...
...
xeth/xeth.go
浏览文件 @
c8a9a4e7
...
...
@@ -885,12 +885,29 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
from
=
common
.
HexToAddress
(
fromStr
)
to
=
common
.
HexToAddress
(
toStr
)
value
=
common
.
Big
(
valueStr
)
gas
=
common
.
Big
(
gasStr
)
price
=
common
.
Big
(
gasPriceStr
)
gas
*
big
.
Int
price
*
big
.
Int
data
[]
byte
contractCreation
bool
)
if
len
(
gasStr
)
==
0
{
gas
=
DefaultGas
()
}
else
{
gas
=
common
.
Big
(
gasStr
)
}
if
len
(
gasPriceStr
)
==
0
{
price
=
DefaultGasPrice
()
}
else
{
price
=
common
.
Big
(
gasPriceStr
)
}
data
=
common
.
FromHex
(
codeStr
)
if
len
(
toStr
)
==
0
{
contractCreation
=
true
}
// 2015-05-18 Is this still needed?
// TODO if no_private_key then
//if _, exists := p.register[args.From]; exists {
...
...
@@ -916,18 +933,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
// TODO: align default values to have the same type, e.g. not depend on
// common.Value conversions later on
if
gas
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
gas
=
DefaultGas
()
}
if
price
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
price
=
DefaultGasPrice
()
}
data
=
common
.
FromHex
(
codeStr
)
if
len
(
toStr
)
==
0
{
contractCreation
=
true
}
var
tx
*
types
.
Transaction
if
contractCreation
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录