Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
8812c4d3
Commit
8812c4d3
authored
Jul 25, 2019
by
gary rong
Committed by
Péter Szilágyi
Jul 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth, graphql, internal/ethapi, les: polish and improve graphql (#19886)
parent
e4232c15
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
96 deletions
+49
-96
api_backend.go
eth/api_backend.go
+4
-8
graphql.go
graphql/graphql.go
+32
-70
api.go
internal/ethapi/api.go
+7
-7
backend.go
internal/ethapi/backend.go
+1
-2
api_backend.go
les/api_backend.go
+5
-9
No files found.
eth/api_backend.go
View file @
8812c4d3
...
...
@@ -89,6 +89,10 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
return
b
.
eth
.
blockchain
.
GetBlockByNumber
(
uint64
(
number
)),
nil
}
func
(
b
*
EthAPIBackend
)
BlockByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
return
b
.
eth
.
blockchain
.
GetBlockByHash
(
hash
),
nil
}
func
(
b
*
EthAPIBackend
)
StateAndHeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
state
.
StateDB
,
*
types
.
Header
,
error
)
{
// Pending state is only known by the miner
if
number
==
rpc
.
PendingBlockNumber
{
...
...
@@ -107,14 +111,6 @@ func (b *EthAPIBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.B
return
stateDb
,
header
,
err
}
func
(
b
*
EthAPIBackend
)
GetHeader
(
ctx
context
.
Context
,
hash
common
.
Hash
)
*
types
.
Header
{
return
b
.
eth
.
blockchain
.
GetHeaderByHash
(
hash
)
}
func
(
b
*
EthAPIBackend
)
GetBlock
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
return
b
.
eth
.
blockchain
.
GetBlockByHash
(
hash
),
nil
}
func
(
b
*
EthAPIBackend
)
GetReceipts
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
types
.
Receipts
,
error
)
{
return
b
.
eth
.
blockchain
.
GetReceiptsByHash
(
hash
),
nil
}
...
...
graphql/graphql.go
View file @
8812c4d3
This diff is collapsed.
Click to expand it.
internal/ethapi/api.go
View file @
8812c4d3
...
...
@@ -636,7 +636,7 @@ func (s *PublicBlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.
// GetHeaderByHash returns the requested header by hash.
func
(
s
*
PublicBlockChainAPI
)
GetHeaderByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
map
[
string
]
interface
{}
{
header
:=
s
.
b
.
GetHeader
(
ctx
,
hash
)
header
,
_
:=
s
.
b
.
HeaderByHash
(
ctx
,
hash
)
if
header
!=
nil
{
return
s
.
rpcMarshalHeader
(
header
)
}
...
...
@@ -666,7 +666,7 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
// GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full
// detail, otherwise only the transaction hash is returned.
func
(
s
*
PublicBlockChainAPI
)
GetBlockByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
,
fullTx
bool
)
(
map
[
string
]
interface
{},
error
)
{
block
,
err
:=
s
.
b
.
GetBlock
(
ctx
,
hash
)
block
,
err
:=
s
.
b
.
BlockByHash
(
ctx
,
hash
)
if
block
!=
nil
{
return
s
.
rpcMarshalBlock
(
block
,
true
,
fullTx
)
}
...
...
@@ -692,7 +692,7 @@ func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context,
// GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true
// all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func
(
s
*
PublicBlockChainAPI
)
GetUncleByBlockHashAndIndex
(
ctx
context
.
Context
,
blockHash
common
.
Hash
,
index
hexutil
.
Uint
)
(
map
[
string
]
interface
{},
error
)
{
block
,
err
:=
s
.
b
.
GetBlock
(
ctx
,
blockHash
)
block
,
err
:=
s
.
b
.
BlockByHash
(
ctx
,
blockHash
)
if
block
!=
nil
{
uncles
:=
block
.
Uncles
()
if
index
>=
hexutil
.
Uint
(
len
(
uncles
))
{
...
...
@@ -716,7 +716,7 @@ func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, bl
// GetUncleCountByBlockHash returns number of uncles in the block for the given block hash
func
(
s
*
PublicBlockChainAPI
)
GetUncleCountByBlockHash
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
*
hexutil
.
Uint
{
if
block
,
_
:=
s
.
b
.
GetBlock
(
ctx
,
blockHash
);
block
!=
nil
{
if
block
,
_
:=
s
.
b
.
BlockByHash
(
ctx
,
blockHash
);
block
!=
nil
{
n
:=
hexutil
.
Uint
(
len
(
block
.
Uncles
()))
return
&
n
}
...
...
@@ -1146,7 +1146,7 @@ func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.
// GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.
func
(
s
*
PublicTransactionPoolAPI
)
GetBlockTransactionCountByHash
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
*
hexutil
.
Uint
{
if
block
,
_
:=
s
.
b
.
GetBlock
(
ctx
,
blockHash
);
block
!=
nil
{
if
block
,
_
:=
s
.
b
.
BlockByHash
(
ctx
,
blockHash
);
block
!=
nil
{
n
:=
hexutil
.
Uint
(
len
(
block
.
Transactions
()))
return
&
n
}
...
...
@@ -1163,7 +1163,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx conte
// GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.
func
(
s
*
PublicTransactionPoolAPI
)
GetTransactionByBlockHashAndIndex
(
ctx
context
.
Context
,
blockHash
common
.
Hash
,
index
hexutil
.
Uint
)
*
RPCTransaction
{
if
block
,
_
:=
s
.
b
.
GetBlock
(
ctx
,
blockHash
);
block
!=
nil
{
if
block
,
_
:=
s
.
b
.
BlockByHash
(
ctx
,
blockHash
);
block
!=
nil
{
return
newRPCTransactionFromBlockIndex
(
block
,
uint64
(
index
))
}
return
nil
...
...
@@ -1179,7 +1179,7 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx co
// GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.
func
(
s
*
PublicTransactionPoolAPI
)
GetRawTransactionByBlockHashAndIndex
(
ctx
context
.
Context
,
blockHash
common
.
Hash
,
index
hexutil
.
Uint
)
hexutil
.
Bytes
{
if
block
,
_
:=
s
.
b
.
GetBlock
(
ctx
,
blockHash
);
block
!=
nil
{
if
block
,
_
:=
s
.
b
.
BlockByHash
(
ctx
,
blockHash
);
block
!=
nil
{
return
newRPCRawTransactionFromBlockIndex
(
block
,
uint64
(
index
))
}
return
nil
...
...
internal/ethapi/backend.go
View file @
8812c4d3
...
...
@@ -53,9 +53,8 @@ type Backend interface {
HeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
types
.
Header
,
error
)
HeaderByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Header
,
error
)
BlockByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
types
.
Block
,
error
)
BlockByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
StateAndHeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
state
.
StateDB
,
*
types
.
Header
,
error
)
GetHeader
(
ctx
context
.
Context
,
hash
common
.
Hash
)
*
types
.
Header
GetBlock
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
GetReceipts
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
types
.
Receipts
,
error
)
GetTd
(
hash
common
.
Hash
)
*
big
.
Int
GetEVM
(
ctx
context
.
Context
,
msg
core
.
Message
,
state
*
state
.
StateDB
,
header
*
types
.
Header
)
(
*
vm
.
EVM
,
func
()
error
,
error
)
...
...
les/api_backend.go
View file @
8812c4d3
...
...
@@ -74,7 +74,11 @@ func (b *LesApiBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
if
header
==
nil
||
err
!=
nil
{
return
nil
,
err
}
return
b
.
GetBlock
(
ctx
,
header
.
Hash
())
return
b
.
BlockByHash
(
ctx
,
header
.
Hash
())
}
func
(
b
*
LesApiBackend
)
BlockByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
return
b
.
eth
.
blockchain
.
GetBlockByHash
(
ctx
,
hash
)
}
func
(
b
*
LesApiBackend
)
StateAndHeaderByNumber
(
ctx
context
.
Context
,
number
rpc
.
BlockNumber
)
(
*
state
.
StateDB
,
*
types
.
Header
,
error
)
{
...
...
@@ -88,14 +92,6 @@ func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.B
return
light
.
NewState
(
ctx
,
header
,
b
.
eth
.
odr
),
header
,
nil
}
func
(
b
*
LesApiBackend
)
GetHeader
(
ctx
context
.
Context
,
hash
common
.
Hash
)
*
types
.
Header
{
return
b
.
eth
.
blockchain
.
GetHeaderByHash
(
hash
)
}
func
(
b
*
LesApiBackend
)
GetBlock
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
return
b
.
eth
.
blockchain
.
GetBlockByHash
(
ctx
,
hash
)
}
func
(
b
*
LesApiBackend
)
GetReceipts
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
types
.
Receipts
,
error
)
{
if
number
:=
rawdb
.
ReadHeaderNumber
(
b
.
eth
.
chainDb
,
hash
);
number
!=
nil
{
return
light
.
GetBlockReceipts
(
ctx
,
b
.
eth
.
odr
,
hash
,
*
number
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment