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
76d4ac1a
Unverified
Commit
76d4ac1a
authored
Aug 23, 2023
by
Shude Li
Committed by
GitHub
Aug 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
account/abi: convert if-else-if chain to tagged switch (#27869)
account/abi: conver if-else-if chain to tagged switch
parent
4af98d4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
+12
-9
method.go
accounts/abi/method.go
+4
-3
method_test.go
accounts/abi/method_test.go
+4
-3
unpack.go
accounts/abi/unpack.go
+4
-3
No files found.
accounts/abi/method.go
View file @
76d4ac1a
...
...
@@ -127,11 +127,12 @@ func NewMethod(name string, rawName string, funType FunctionType, mutability str
state
=
state
+
" "
}
identity
:=
fmt
.
Sprintf
(
"function %v"
,
rawName
)
if
funType
==
Fallback
{
switch
funType
{
case
Fallback
:
identity
=
"fallback"
}
else
if
funType
==
Receive
{
case
Receive
:
identity
=
"receive"
}
else
if
funType
==
Constructor
{
case
Constructor
:
identity
=
"constructor"
}
str
:=
fmt
.
Sprintf
(
"%v(%v) %sreturns(%v)"
,
identity
,
strings
.
Join
(
inputNames
,
", "
),
state
,
strings
.
Join
(
outputNames
,
", "
))
...
...
accounts/abi/method_test.go
View file @
76d4ac1a
...
...
@@ -84,11 +84,12 @@ func TestMethodString(t *testing.T) {
for
_
,
test
:=
range
table
{
var
got
string
if
test
.
method
==
"fallback"
{
switch
test
.
method
{
case
"fallback"
:
got
=
abi
.
Fallback
.
String
()
}
else
if
test
.
method
==
"receive"
{
case
"receive"
:
got
=
abi
.
Receive
.
String
()
}
else
{
default
:
got
=
abi
.
Methods
[
test
.
method
]
.
String
()
}
if
got
!=
test
.
expectation
{
...
...
accounts/abi/unpack.go
View file @
76d4ac1a
...
...
@@ -160,13 +160,14 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
// this value will become our slice or our array, depending on the type
var
refSlice
reflect
.
Value
if
t
.
T
==
SliceTy
{
switch
t
.
T
{
case
SliceTy
:
// declare our slice
refSlice
=
reflect
.
MakeSlice
(
t
.
GetType
(),
size
,
size
)
}
else
if
t
.
T
==
ArrayTy
{
case
ArrayTy
:
// declare our array
refSlice
=
reflect
.
New
(
t
.
GetType
())
.
Elem
()
}
else
{
default
:
return
nil
,
errors
.
New
(
"abi: invalid type in array/slice unpacking stage"
)
}
...
...
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