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
5dd56bb4
Commit
5dd56bb4
authored
Apr 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
geth: admin download status
parent
2c1a6a34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
admin.go
cmd/geth/admin.go
+7
-0
downloader.go
eth/downloader/downloader.go
+15
-11
No files found.
cmd/geth/admin.go
View file @
5dd56bb4
...
...
@@ -34,6 +34,7 @@ func (js *jsre) adminBindings() {
admin
.
Set
(
"export"
,
js
.
exportChain
)
admin
.
Set
(
"verbosity"
,
js
.
verbosity
)
admin
.
Set
(
"backtrace"
,
js
.
backtrace
)
admin
.
Set
(
"progress"
,
js
.
downloadProgress
)
admin
.
Set
(
"miner"
,
struct
{}{})
t
,
_
=
admin
.
Get
(
"miner"
)
...
...
@@ -51,6 +52,12 @@ func (js *jsre) adminBindings() {
debug
.
Set
(
"getBlockRlp"
,
js
.
getBlockRlp
)
}
func
(
js
*
jsre
)
downloadProgress
(
call
otto
.
FunctionCall
)
otto
.
Value
{
current
,
max
:=
js
.
ethereum
.
Downloader
()
.
Stats
()
return
js
.
re
.
ToVal
(
fmt
.
Sprintf
(
"%d/%d"
,
current
,
max
))
}
func
(
js
*
jsre
)
getBlockRlp
(
call
otto
.
FunctionCall
)
otto
.
Value
{
var
block
*
types
.
Block
if
len
(
call
.
ArgumentList
)
>
0
{
...
...
eth/downloader/downloader.go
View file @
5dd56bb4
...
...
@@ -41,6 +41,17 @@ type chainInsertFn func(types.Blocks) error
type
hashIterFn
func
()
(
common
.
Hash
,
error
)
type
currentTdFn
func
()
*
big
.
Int
type
blockPack
struct
{
peerId
string
blocks
[]
*
types
.
Block
}
type
syncPack
struct
{
peer
*
peer
hash
common
.
Hash
ignoreInitial
bool
}
type
Downloader
struct
{
mu
sync
.
RWMutex
queue
*
queue
...
...
@@ -65,17 +76,6 @@ type Downloader struct {
quit
chan
struct
{}
}
type
blockPack
struct
{
peerId
string
blocks
[]
*
types
.
Block
}
type
syncPack
struct
{
peer
*
peer
hash
common
.
Hash
ignoreInitial
bool
}
func
New
(
hasBlock
hashCheckFn
,
insertChain
chainInsertFn
,
currentTd
currentTdFn
)
*
Downloader
{
downloader
:=
&
Downloader
{
queue
:
newqueue
(),
...
...
@@ -95,6 +95,10 @@ func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn)
return
downloader
}
func
(
d
*
Downloader
)
Stats
()
(
current
int
,
max
int
)
{
return
d
.
queue
.
blockHashes
.
Size
(),
d
.
queue
.
fetchPool
.
Size
()
+
d
.
queue
.
hashPool
.
Size
()
}
func
(
d
*
Downloader
)
RegisterPeer
(
id
string
,
td
*
big
.
Int
,
hash
common
.
Hash
,
getHashes
hashFetcherFn
,
getBlocks
blockFetcherFn
)
error
{
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
...
...
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