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
3ab9f269
Commit
3ab9f269
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept number or string for BlockFilterArgs limit/offset
parent
6661bc35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
args.go
rpc/args.go
+26
-14
No files found.
rpc/args.go
View file @
3ab9f269
...
@@ -42,6 +42,24 @@ func blockHeight(raw interface{}, number *int64) error {
...
@@ -42,6 +42,24 @@ func blockHeight(raw interface{}, number *int64) error {
return
nil
return
nil
}
}
func
numString
(
raw
interface
{},
number
*
int64
)
error
{
// Parse as integer
num
,
ok
:=
raw
.
(
float64
)
if
ok
{
*
number
=
int64
(
num
)
return
nil
}
// Parse as string/hexstring
str
,
ok
:=
raw
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
""
,
"not a number or string"
)
}
*
number
=
common
.
String2Big
(
str
)
.
Int64
()
return
nil
}
type
GetBlockByHashArgs
struct
{
type
GetBlockByHashArgs
struct
{
BlockHash
common
.
Hash
BlockHash
common
.
Hash
IncludeTxs
bool
IncludeTxs
bool
...
@@ -410,8 +428,8 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -410,8 +428,8 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
var
obj
[]
struct
{
var
obj
[]
struct
{
FromBlock
interface
{}
`json:"fromBlock"`
FromBlock
interface
{}
`json:"fromBlock"`
ToBlock
interface
{}
`json:"toBlock"`
ToBlock
interface
{}
`json:"toBlock"`
Limit
string
`json:"limit"`
Limit
interface
{}
`json:"limit"`
Offset
string
`json:"offset"`
Offset
interface
{}
`json:"offset"`
Address
string
`json:"address"`
Address
string
`json:"address"`
Topics
[]
interface
{}
`json:"topics"`
Topics
[]
interface
{}
`json:"topics"`
}
}
...
@@ -439,22 +457,16 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -439,22 +457,16 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
}
}
args
.
Latest
=
num
args
.
Latest
=
num
tostr
,
ok
:=
obj
[
0
]
.
ToBlock
.
(
string
)
if
err
:=
numString
(
obj
[
0
]
.
Limit
,
&
num
);
err
!=
nil
{
if
!
ok
{
return
err
return
NewInvalidTypeError
(
"toBlock"
,
"not a string"
)
}
}
args
.
Max
=
int
(
num
)
switch
tostr
{
if
err
:=
numString
(
obj
[
0
]
.
Offset
,
&
num
);
err
!=
nil
{
case
"latest"
:
return
err
args
.
Latest
=
-
1
case
"pending"
:
args
.
Latest
=
-
2
default
:
args
.
Latest
=
int64
(
common
.
Big
(
obj
[
0
]
.
ToBlock
.
(
string
))
.
Int64
())
}
}
args
.
Skip
=
int
(
num
)
args
.
Max
=
int
(
common
.
Big
(
obj
[
0
]
.
Limit
)
.
Int64
())
args
.
Skip
=
int
(
common
.
Big
(
obj
[
0
]
.
Offset
)
.
Int64
())
args
.
Address
=
obj
[
0
]
.
Address
args
.
Address
=
obj
[
0
]
.
Address
args
.
Topics
=
obj
[
0
]
.
Topics
args
.
Topics
=
obj
[
0
]
.
Topics
...
...
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