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
10564723
Commit
10564723
authored
Sep 13, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added string casting
parent
c0187930
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
value.go
ethutil/value.go
+6
-4
value_test.go
ethutil/value_test.go
+6
-0
No files found.
ethutil/value.go
View file @
10564723
package
ethutil
package
ethutil
import
(
import
(
"bytes"
"fmt"
"fmt"
"math/big"
"math/big"
"reflect"
"reflect"
"strconv"
)
)
// Data values are returned by the rlp decoder. The data values represents
// Data values are returned by the rlp decoder. The data values represents
...
@@ -93,6 +95,9 @@ func (val *Value) Int() int64 {
...
@@ -93,6 +95,9 @@ func (val *Value) Int() int64 {
return
new
(
big
.
Int
)
.
SetBytes
(
Val
)
.
Int64
()
return
new
(
big
.
Int
)
.
SetBytes
(
Val
)
.
Int64
()
}
else
if
Val
,
ok
:=
val
.
Val
.
(
*
big
.
Int
);
ok
{
}
else
if
Val
,
ok
:=
val
.
Val
.
(
*
big
.
Int
);
ok
{
return
Val
.
Int64
()
return
Val
.
Int64
()
}
else
if
Val
,
ok
:=
val
.
Val
.
(
string
);
ok
{
n
,
_
:=
strconv
.
Atoi
(
Val
)
return
int64
(
n
)
}
}
return
0
return
0
...
@@ -246,10 +251,7 @@ func (val *Value) Cmp(o *Value) bool {
...
@@ -246,10 +251,7 @@ func (val *Value) Cmp(o *Value) bool {
}
}
func
(
self
*
Value
)
DeepCmp
(
o
*
Value
)
bool
{
func
(
self
*
Value
)
DeepCmp
(
o
*
Value
)
bool
{
a
:=
NewValue
(
self
.
BigInt
())
return
bytes
.
Compare
(
self
.
Bytes
(),
o
.
Bytes
())
==
0
b
:=
NewValue
(
o
.
BigInt
())
return
a
.
Cmp
(
b
)
}
}
func
(
val
*
Value
)
Encode
()
[]
byte
{
func
(
val
*
Value
)
Encode
()
[]
byte
{
...
...
ethutil/value_test.go
View file @
10564723
...
@@ -2,6 +2,7 @@ package ethutil
...
@@ -2,6 +2,7 @@ package ethutil
import
(
import
(
"bytes"
"bytes"
"fmt"
"math/big"
"math/big"
"testing"
"testing"
)
)
...
@@ -78,3 +79,8 @@ func TestMath(t *testing.T) {
...
@@ -78,3 +79,8 @@ func TestMath(t *testing.T) {
t
.
Error
(
"Expected 0, got"
,
a
)
t
.
Error
(
"Expected 0, got"
,
a
)
}
}
}
}
func
TestString
(
t
*
testing
.
T
)
{
a
:=
NewValue
(
"10"
)
fmt
.
Println
(
"VALUE WITH STRING:"
,
a
.
Int
())
}
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