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
1d74086b
Commit
1d74086b
authored
Apr 2, 2015
by
Taylor Gerring
Browse files
Options
Downloads
Patches
Plain Diff
New UncleRes type
parent
9bdf0b65
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rpc/api.go
+2
-6
2 additions, 6 deletions
rpc/api.go
rpc/responses.go
+54
-5
54 additions, 5 deletions
rpc/responses.go
with
56 additions
and
11 deletions
rpc/api.go
+
2
−
6
View file @
1d74086b
...
@@ -256,9 +256,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -256,9 +256,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
// return NewValidationError("Index", "does not exist")
// return NewValidationError("Index", "does not exist")
*
reply
=
nil
*
reply
=
nil
}
else
{
}
else
{
uhash
:=
br
.
Uncles
[
args
.
Index
]
*
reply
=
br
.
Uncles
[
args
.
Index
]
uncle
:=
NewBlockRes
(
api
.
xeth
()
.
EthBlockByHash
(
uhash
.
String
()),
true
)
*
reply
=
uncle
}
}
case
"eth_getUncleByBlockNumberAndIndex"
:
case
"eth_getUncleByBlockNumberAndIndex"
:
args
:=
new
(
BlockNumIndexArgs
)
args
:=
new
(
BlockNumIndexArgs
)
...
@@ -278,9 +276,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -278,9 +276,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
// return NewValidationError("Index", "does not exist")
// return NewValidationError("Index", "does not exist")
*
reply
=
nil
*
reply
=
nil
}
else
{
}
else
{
uhash
:=
v
.
Uncles
[
args
.
Index
]
*
reply
=
v
.
Uncles
[
args
.
Index
]
uncle
:=
NewBlockRes
(
api
.
xeth
()
.
EthBlockByHash
(
uhash
.
String
()),
false
)
*
reply
=
uncle
}
}
case
"eth_getCompilers"
:
case
"eth_getCompilers"
:
c
:=
[]
string
{
""
}
c
:=
[]
string
{
""
}
...
...
This diff is collapsed.
Click to expand it.
rpc/responses.go
+
54
−
5
View file @
1d74086b
...
@@ -28,7 +28,7 @@ type BlockRes struct {
...
@@ -28,7 +28,7 @@ type BlockRes struct {
GasUsed
*
hexnum
`json:"gasUsed"`
GasUsed
*
hexnum
`json:"gasUsed"`
UnixTimestamp
*
hexnum
`json:"timestamp"`
UnixTimestamp
*
hexnum
`json:"timestamp"`
Transactions
[]
*
TransactionRes
`json:"transactions"`
Transactions
[]
*
TransactionRes
`json:"transactions"`
Uncles
[]
*
hexdata
`json:"uncles"`
Uncles
[]
*
UncleRes
`json:"uncles"`
}
}
func
(
b
*
BlockRes
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
b
*
BlockRes
)
MarshalJSON
()
([]
byte
,
error
)
{
...
@@ -73,7 +73,10 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
...
@@ -73,7 +73,10 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
ext
.
GasUsed
=
b
.
GasUsed
ext
.
GasUsed
=
b
.
GasUsed
ext
.
UnixTimestamp
=
b
.
UnixTimestamp
ext
.
UnixTimestamp
=
b
.
UnixTimestamp
ext
.
Transactions
=
b
.
Transactions
ext
.
Transactions
=
b
.
Transactions
ext
.
Uncles
=
b
.
Uncles
ext
.
Uncles
=
make
([]
*
hexdata
,
len
(
b
.
Uncles
))
for
i
,
u
:=
range
b
.
Uncles
{
ext
.
Uncles
[
i
]
=
u
.
BlockHash
}
return
json
.
Marshal
(
ext
)
return
json
.
Marshal
(
ext
)
}
else
{
}
else
{
var
ext
struct
{
var
ext
struct
{
...
@@ -119,7 +122,10 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
...
@@ -119,7 +122,10 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
for
i
,
tx
:=
range
b
.
Transactions
{
for
i
,
tx
:=
range
b
.
Transactions
{
ext
.
Transactions
[
i
]
=
tx
.
Hash
ext
.
Transactions
[
i
]
=
tx
.
Hash
}
}
ext
.
Uncles
=
b
.
Uncles
ext
.
Uncles
=
make
([]
*
hexdata
,
len
(
b
.
Uncles
))
for
i
,
u
:=
range
b
.
Uncles
{
ext
.
Uncles
[
i
]
=
u
.
BlockHash
}
return
json
.
Marshal
(
ext
)
return
json
.
Marshal
(
ext
)
}
}
}
}
...
@@ -157,9 +163,9 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
...
@@ -157,9 +163,9 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
res
.
Transactions
[
i
]
.
TxIndex
=
newHexNum
(
i
)
res
.
Transactions
[
i
]
.
TxIndex
=
newHexNum
(
i
)
}
}
res
.
Uncles
=
make
([]
*
hexdata
,
len
(
block
.
Uncles
()))
res
.
Uncles
=
make
([]
*
UncleRes
,
len
(
block
.
Uncles
()))
for
i
,
uncle
:=
range
block
.
Uncles
()
{
for
i
,
uncle
:=
range
block
.
Uncles
()
{
res
.
Uncles
[
i
]
=
n
ew
HexData
(
uncle
.
Hash
()
)
res
.
Uncles
[
i
]
=
N
ew
UncleRes
(
uncle
)
}
}
return
res
return
res
...
@@ -200,6 +206,49 @@ func NewTransactionRes(tx *types.Transaction) *TransactionRes {
...
@@ -200,6 +206,49 @@ func NewTransactionRes(tx *types.Transaction) *TransactionRes {
return
v
return
v
}
}
type
UncleRes
struct
{
BlockNumber
*
hexnum
`json:"number"`
BlockHash
*
hexdata
`json:"hash"`
ParentHash
*
hexdata
`json:"parentHash"`
Nonce
*
hexdata
`json:"nonce"`
Sha3Uncles
*
hexdata
`json:"sha3Uncles"`
ReceiptHash
*
hexdata
`json:"receiptHash"`
LogsBloom
*
hexdata
`json:"logsBloom"`
TransactionRoot
*
hexdata
`json:"transactionsRoot"`
StateRoot
*
hexdata
`json:"stateRoot"`
Miner
*
hexdata
`json:"miner"`
Difficulty
*
hexnum
`json:"difficulty"`
ExtraData
*
hexdata
`json:"extraData"`
GasLimit
*
hexnum
`json:"gasLimit"`
GasUsed
*
hexnum
`json:"gasUsed"`
UnixTimestamp
*
hexnum
`json:"timestamp"`
}
func
NewUncleRes
(
h
*
types
.
Header
)
*
UncleRes
{
if
h
==
nil
{
return
nil
}
var
v
=
new
(
UncleRes
)
v
.
BlockNumber
=
newHexNum
(
h
.
Number
)
v
.
BlockHash
=
newHexData
(
h
.
Hash
())
v
.
ParentHash
=
newHexData
(
h
.
ParentHash
)
v
.
Sha3Uncles
=
newHexData
(
h
.
UncleHash
)
v
.
Nonce
=
newHexData
(
h
.
Nonce
[
:
])
v
.
LogsBloom
=
newHexData
(
h
.
Bloom
)
v
.
TransactionRoot
=
newHexData
(
h
.
TxHash
)
v
.
StateRoot
=
newHexData
(
h
.
Root
)
v
.
Miner
=
newHexData
(
h
.
Coinbase
)
v
.
Difficulty
=
newHexNum
(
h
.
Difficulty
)
v
.
ExtraData
=
newHexData
(
h
.
Extra
)
v
.
GasLimit
=
newHexNum
(
h
.
GasLimit
)
v
.
GasUsed
=
newHexNum
(
h
.
GasUsed
)
v
.
UnixTimestamp
=
newHexNum
(
h
.
Time
)
v
.
ReceiptHash
=
newHexData
(
h
.
ReceiptHash
)
return
v
}
// type FilterLogRes struct {
// type FilterLogRes struct {
// Hash string `json:"hash"`
// Hash string `json:"hash"`
// Address string `json:"address"`
// Address string `json:"address"`
...
...
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