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
6afc1639
Commit
6afc1639
authored
Aug 25, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Block size
parent
3f904bf3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
2 deletions
+35
-2
block.go
ethchain/block.go
+6
-1
js_types.go
ethpipe/js_types.go
+2
-1
size.go
ethutil/size.go
+15
-0
size_test.go
ethutil/size_test.go
+12
-0
No files found.
ethchain/block.go
View file @
6afc1639
...
...
@@ -351,7 +351,7 @@ func (block *Block) header() []interface{} {
func
(
block
*
Block
)
String
()
string
{
return
fmt
.
Sprintf
(
`
BLOCK(%x):
BLOCK(%x):
Size: %v
PrevHash: %x
UncleSha: %x
Coinbase: %x
...
...
@@ -368,6 +368,7 @@ func (block *Block) String() string {
NumTx: %v
`
,
block
.
Hash
(),
block
.
Size
(),
block
.
PrevHash
,
block
.
UncleSha
,
block
.
Coinbase
,
...
...
@@ -384,3 +385,7 @@ func (block *Block) String() string {
len
(
block
.
transactions
),
)
}
func
(
self
*
Block
)
Size
()
ethutil
.
StorageSize
{
return
ethutil
.
StorageSize
(
len
(
self
.
RlpEncode
()))
}
ethpipe/js_types.go
View file @
6afc1639
...
...
@@ -14,6 +14,7 @@ import (
// Block interface exposed to QML
type
JSBlock
struct
{
ref
*
ethchain
.
Block
Size
string
`json:"size"`
Number
int
`json:"number"`
Hash
string
`json:"hash"`
Transactions
string
`json:"transactions"`
...
...
@@ -40,7 +41,7 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
return
nil
}
return
&
JSBlock
{
ref
:
block
,
Number
:
int
(
block
.
Number
.
Uint64
()),
GasUsed
:
block
.
GasUsed
.
String
(),
GasLimit
:
block
.
GasLimit
.
String
(),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
()),
Transactions
:
string
(
txJson
),
Time
:
block
.
Time
,
Coinbase
:
ethutil
.
Bytes2Hex
(
block
.
Coinbase
)}
return
&
JSBlock
{
ref
:
block
,
Size
:
block
.
Size
()
.
String
(),
Number
:
int
(
block
.
Number
.
Uint64
()),
GasUsed
:
block
.
GasUsed
.
String
(),
GasLimit
:
block
.
GasLimit
.
String
(),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
()),
Transactions
:
string
(
txJson
),
Time
:
block
.
Time
,
Coinbase
:
ethutil
.
Bytes2Hex
(
block
.
Coinbase
)}
}
func
(
self
*
JSBlock
)
ToString
()
string
{
...
...
ethutil/size.go
0 → 100644
View file @
6afc1639
package
ethutil
import
"fmt"
type
StorageSize
float64
func
(
self
StorageSize
)
String
()
string
{
if
self
>
1000000
{
return
fmt
.
Sprintf
(
"%.2f mB"
,
self
/
1000000
)
}
else
if
self
>
1000
{
return
fmt
.
Sprintf
(
"%.2f kB"
,
self
/
1000
)
}
else
{
return
fmt
.
Sprintf
(
"%.2f B"
,
self
)
}
}
ethutil/size_test.go
0 → 100644
View file @
6afc1639
package
ethutil
import
(
"fmt"
"testing"
)
func
TestSize
(
t
*
testing
.
T
)
{
fmt
.
Println
(
StorageSize
(
2381273
))
fmt
.
Println
(
StorageSize
(
2192
))
fmt
.
Println
(
StorageSize
(
12
))
}
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