good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
bef78efb
Unverified
Commit
bef78efb
authored
Jun 22, 2021
by
Gary Rong
Committed by
GitHub
Jun 22, 2021
Browse files
Options
Downloads
Patches
Plain Diff
graphql: fix transaction API (#23052)
parent
ddf10250
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
graphql/graphql.go
+19
-7
19 additions, 7 deletions
graphql/graphql.go
with
19 additions
and
7 deletions
graphql/graphql.go
+
19
−
7
View file @
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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment