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
793e666f
Commit
793e666f
authored
Aug 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dump bytes instead of strings
parent
4008ff32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
dump.go
ethstate/dump.go
+2
-2
common.go
ethutil/common.go
+26
-9
No files found.
ethstate/dump.go
View file @
793e666f
...
@@ -19,7 +19,7 @@ type World struct {
...
@@ -19,7 +19,7 @@ type World struct {
Accounts
map
[
string
]
Account
`json:"accounts"`
Accounts
map
[
string
]
Account
`json:"accounts"`
}
}
func
(
self
*
State
)
Dump
()
string
{
func
(
self
*
State
)
Dump
()
[]
byte
{
world
:=
World
{
world
:=
World
{
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
Root
.
([]
byte
)),
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
Root
.
([]
byte
)),
Accounts
:
make
(
map
[
string
]
Account
),
Accounts
:
make
(
map
[
string
]
Account
),
...
@@ -43,5 +43,5 @@ func (self *State) Dump() string {
...
@@ -43,5 +43,5 @@ func (self *State) Dump() string {
fmt
.
Println
(
"dump err"
,
err
)
fmt
.
Println
(
"dump err"
,
err
)
}
}
return
string
(
json
)
return
json
}
}
ethutil/common.go
View file @
793e666f
...
@@ -34,26 +34,43 @@ var (
...
@@ -34,26 +34,43 @@ var (
// Currency to string
// Currency to string
// Returns a string representing a human readable format
// Returns a string representing a human readable format
func
CurrencyToString
(
num
*
big
.
Int
)
string
{
func
CurrencyToString
(
num
*
big
.
Int
)
string
{
var
(
fin
*
big
.
Int
=
num
denom
string
=
"Wei"
)
switch
{
switch
{
case
num
.
Cmp
(
Douglas
)
>=
0
:
case
num
.
Cmp
(
Douglas
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Douglas"
,
new
(
big
.
Int
)
.
Div
(
num
,
Douglas
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Douglas
)
denom
=
"Douglas"
case
num
.
Cmp
(
Einstein
)
>=
0
:
case
num
.
Cmp
(
Einstein
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Einstein"
,
new
(
big
.
Int
)
.
Div
(
num
,
Einstein
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Einstein
)
denom
=
"Einstein"
case
num
.
Cmp
(
Ether
)
>=
0
:
case
num
.
Cmp
(
Ether
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Ether"
,
new
(
big
.
Int
)
.
Div
(
num
,
Ether
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Ether
)
denom
=
"Ether"
case
num
.
Cmp
(
Finney
)
>=
0
:
case
num
.
Cmp
(
Finney
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Finney"
,
new
(
big
.
Int
)
.
Div
(
num
,
Finney
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Finney
)
denom
=
"Finney"
case
num
.
Cmp
(
Szabo
)
>=
0
:
case
num
.
Cmp
(
Szabo
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Szabo"
,
new
(
big
.
Int
)
.
Div
(
num
,
Szabo
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Szabo
)
denom
=
"Szabo"
case
num
.
Cmp
(
Shannon
)
>=
0
:
case
num
.
Cmp
(
Shannon
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Shannon"
,
new
(
big
.
Int
)
.
Div
(
num
,
Shannon
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Shannon
)
denom
=
"Shannon"
case
num
.
Cmp
(
Babbage
)
>=
0
:
case
num
.
Cmp
(
Babbage
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Babbage"
,
new
(
big
.
Int
)
.
Div
(
num
,
Babbage
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Babbage
)
denom
=
"Babbage"
case
num
.
Cmp
(
Ada
)
>=
0
:
case
num
.
Cmp
(
Ada
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Ada"
,
new
(
big
.
Int
)
.
Div
(
num
,
Ada
))
fin
=
new
(
big
.
Int
)
.
Div
(
num
,
Ada
)
denom
=
"Ada"
}
if
len
(
fin
.
String
())
>
5
{
return
fmt
.
Sprintf
(
"%sE%d %s"
,
fin
.
String
()[
0
:
5
],
len
(
fin
.
String
())
-
5
,
denom
)
}
}
return
fmt
.
Sprintf
(
"%v
Wei"
,
nu
m
)
return
fmt
.
Sprintf
(
"%v
%s"
,
fin
,
deno
m
)
}
}
// Common big integers often used
// Common big integers often used
...
...
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