Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
bef78efb
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,发现更多精彩内容 >>
未验证
提交
bef78efb
编写于
6月 22, 2021
作者:
G
gary rong
提交者:
GitHub
6月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
graphql: fix transaction API (#23052)
上级
ddf10250
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
7 deletion
+19
-7
graphql/graphql.go
graphql/graphql.go
+19
-7
未找到文件。
graphql/graphql.go
浏览文件 @
bef78efb
...
...
@@ -29,7 +29,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
...
...
@@ -94,7 +93,11 @@ func (a *Account) Balance(ctx context.Context) (hexutil.Big, error) {
if
err
!=
nil
{
return
hexutil
.
Big
{},
err
}
return
hexutil
.
Big
(
*
state
.
GetBalance
(
a
.
address
)),
nil
balance
:=
state
.
GetBalance
(
a
.
address
)
if
balance
==
nil
{
return
hexutil
.
Big
{},
fmt
.
Errorf
(
"failed to load balance %x"
,
a
.
address
)
}
return
hexutil
.
Big
(
*
balance
),
nil
}
func
(
a
*
Account
)
TransactionCount
(
ctx
context
.
Context
)
(
hexutil
.
Uint64
,
error
)
{
...
...
@@ -179,8 +182,9 @@ type Transaction struct {
// resolve returns the internal transaction object, fetching it if needed.
func
(
t
*
Transaction
)
resolve
(
ctx
context
.
Context
)
(
*
types
.
Transaction
,
error
)
{
if
t
.
tx
==
nil
{
tx
,
blockHash
,
_
,
index
:=
rawdb
.
ReadTransaction
(
t
.
backend
.
ChainDb
(),
t
.
hash
)
if
tx
!=
nil
{
// Try to return an already finalized transaction
tx
,
blockHash
,
_
,
index
,
err
:=
t
.
backend
.
GetTransaction
(
ctx
,
t
.
hash
)
if
err
==
nil
&&
tx
!=
nil
{
t
.
tx
=
tx
blockNrOrHash
:=
rpc
.
BlockNumberOrHashWithHash
(
blockHash
,
false
)
t
.
block
=
&
Block
{
...
...
@@ -188,9 +192,10 @@ func (t *Transaction) resolve(ctx context.Context) (*types.Transaction, error) {
numberOrHash
:
&
blockNrOrHash
,
}
t
.
index
=
index
}
else
{
t
.
tx
=
t
.
backend
.
GetPoolTransaction
(
t
.
hash
)
return
t
.
tx
,
nil
}
// No finalized transaction, try to retrieve it from the pool
t
.
tx
=
t
.
backend
.
GetPoolTransaction
(
t
.
hash
)
}
return
t
.
tx
,
nil
}
...
...
@@ -286,6 +291,9 @@ func (t *Transaction) Value(ctx context.Context) (hexutil.Big, error) {
if
err
!=
nil
||
tx
==
nil
{
return
hexutil
.
Big
{},
err
}
if
tx
.
Value
()
==
nil
{
return
hexutil
.
Big
{},
fmt
.
Errorf
(
"invalid transaction value %x"
,
t
.
hash
)
}
return
hexutil
.
Big
(
*
tx
.
Value
()),
nil
}
...
...
@@ -721,7 +729,11 @@ func (b *Block) TotalDifficulty(ctx context.Context) (hexutil.Big, error) {
}
h
=
header
.
Hash
()
}
return
hexutil
.
Big
(
*
b
.
backend
.
GetTd
(
ctx
,
h
)),
nil
td
:=
b
.
backend
.
GetTd
(
ctx
,
h
)
if
td
==
nil
{
return
hexutil
.
Big
{},
fmt
.
Errorf
(
"total difficulty not found %x"
,
b
.
hash
)
}
return
hexutil
.
Big
(
*
td
),
nil
}
// BlockNumberArgs encapsulates arguments to accessors that specify a block number.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录