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
2a1a531b
Commit
2a1a531b
authored
Jan 16, 2017
by
Péter Szilágyi
Committed by
GitHub
Jan 16, 2017
Browse files
Options
Downloads
Plain Diff
Merge pull request #3570 from fjl/hexutil-zero-fix
common/hexutil: fix EncodeBig, Big.MarshalJSON
parents
b5a100b8
51f6b6d3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/hexutil/hexutil.go
+1
-6
1 addition, 6 deletions
common/hexutil/hexutil.go
common/hexutil/hexutil_test.go
+1
-0
1 addition, 0 deletions
common/hexutil/hexutil_test.go
common/hexutil/json.go
+2
-7
2 additions, 7 deletions
common/hexutil/json.go
with
4 additions
and
13 deletions
common/hexutil/hexutil.go
+
1
−
6
View file @
2a1a531b
...
...
@@ -169,12 +169,7 @@ func EncodeBig(bigint *big.Int) string {
if
nbits
==
0
{
return
"0x0"
}
enc
:=
make
([]
byte
,
2
,
(
nbits
/
8
)
*
2
+
2
)
copy
(
enc
,
"0x"
)
for
i
:=
len
(
bigint
.
Bits
())
-
1
;
i
>=
0
;
i
--
{
enc
=
strconv
.
AppendUint
(
enc
,
uint64
(
bigint
.
Bits
()[
i
]),
16
)
}
return
string
(
enc
)
return
fmt
.
Sprintf
(
"0x%x"
,
bigint
)
}
func
has0xPrefix
(
input
string
)
bool
{
...
...
This diff is collapsed.
Click to expand it.
common/hexutil/hexutil_test.go
+
1
−
0
View file @
2a1a531b
...
...
@@ -46,6 +46,7 @@ var (
{
referenceBig
(
"1"
),
"0x1"
},
{
referenceBig
(
"ff"
),
"0xff"
},
{
referenceBig
(
"112233445566778899aabbccddeeff"
),
"0x112233445566778899aabbccddeeff"
},
{
referenceBig
(
"80a7f2c1bcc396c00"
),
"0x80a7f2c1bcc396c00"
},
}
encodeUint64Tests
=
[]
marshalTest
{
...
...
This diff is collapsed.
Click to expand it.
common/hexutil/json.go
+
2
−
7
View file @
2a1a531b
...
...
@@ -109,13 +109,8 @@ func (b *Big) MarshalJSON() ([]byte, error) {
if
nbits
==
0
{
return
jsonZero
,
nil
}
enc
:=
make
([]
byte
,
3
,
(
nbits
/
8
)
*
2
+
4
)
copy
(
enc
,
`"0x`
)
for
i
:=
len
(
bigint
.
Bits
())
-
1
;
i
>=
0
;
i
--
{
enc
=
strconv
.
AppendUint
(
enc
,
uint64
(
bigint
.
Bits
()[
i
]),
16
)
}
enc
=
append
(
enc
,
'"'
)
return
enc
,
nil
enc
:=
fmt
.
Sprintf
(
`"0x%x"`
,
bigint
)
return
[]
byte
(
enc
),
nil
}
// UnmarshalJSON implements json.Unmarshaler.
...
...
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