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
b3d5ce7d
Commit
b3d5ce7d
authored
Jun 09, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth, eth/downloader: collect and report import progress too
parent
e972a116
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
8 deletions
+39
-8
admin.go
cmd/geth/admin.go
+4
-4
downloader.go
eth/downloader/downloader.go
+35
-4
No files found.
cmd/geth/admin.go
View file @
b3d5ce7d
...
...
@@ -51,7 +51,7 @@ func (js *jsre) adminBindings() {
admin
.
Set
(
"import"
,
js
.
importChain
)
admin
.
Set
(
"export"
,
js
.
exportChain
)
admin
.
Set
(
"verbosity"
,
js
.
verbosity
)
admin
.
Set
(
"progress"
,
js
.
download
Progress
)
admin
.
Set
(
"progress"
,
js
.
sync
Progress
)
admin
.
Set
(
"setSolc"
,
js
.
setSolc
)
admin
.
Set
(
"contractInfo"
,
struct
{}{})
...
...
@@ -324,9 +324,9 @@ func (js *jsre) setHead(call otto.FunctionCall) otto.Value {
return
otto
.
UndefinedValue
()
}
func
(
js
*
jsre
)
download
Progress
(
call
otto
.
FunctionCall
)
otto
.
Value
{
pending
,
cached
:=
js
.
ethereum
.
Downloader
()
.
Stats
()
v
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"pending"
:
pending
,
"cached"
:
cached
})
func
(
js
*
jsre
)
sync
Progress
(
call
otto
.
FunctionCall
)
otto
.
Value
{
pending
,
cached
,
importing
:=
js
.
ethereum
.
Downloader
()
.
Stats
()
v
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"pending"
:
pending
,
"cached"
:
cached
,
"importing"
:
importing
})
return
v
}
...
...
eth/downloader/downloader.go
View file @
b3d5ce7d
...
...
@@ -78,6 +78,10 @@ type Downloader struct {
checks
map
[
common
.
Hash
]
*
crossCheck
// Pending cross checks to verify a hash chain
banned
*
set
.
Set
// Set of hashes we've received and banned
// Statistics
importQueue
[]
common
.
Hash
// Hashes of the previously taken blocks to check import progress
importLock
sync
.
Mutex
// Callbacks
hasBlock
hashCheckFn
getBlock
getBlockFn
...
...
@@ -121,8 +125,21 @@ func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock getBlockFn) *Downloa
return
downloader
}
func
(
d
*
Downloader
)
Stats
()
(
current
int
,
max
int
)
{
return
d
.
queue
.
Size
()
// Stats retrieves the current status of the downloader.
func
(
d
*
Downloader
)
Stats
()
(
pending
int
,
cached
int
,
importing
int
)
{
// Fetch the download status
pending
,
cached
=
d
.
queue
.
Size
()
// Generate the import status
d
.
importLock
.
Lock
()
defer
d
.
importLock
.
Unlock
()
for
len
(
d
.
importQueue
)
>
0
&&
d
.
hasBlock
(
d
.
importQueue
[
0
])
{
d
.
importQueue
=
d
.
importQueue
[
1
:
]
}
importing
=
len
(
d
.
importQueue
)
return
}
// Synchronising returns the state of the downloader
...
...
@@ -202,7 +219,17 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
// TakeBlocks takes blocks from the queue and yields them to the caller.
func
(
d
*
Downloader
)
TakeBlocks
()
[]
*
Block
{
return
d
.
queue
.
TakeBlocks
()
blocks
:=
d
.
queue
.
TakeBlocks
()
if
len
(
blocks
)
>
0
{
hashes
:=
make
([]
common
.
Hash
,
len
(
blocks
))
for
i
,
block
:=
range
blocks
{
hashes
[
i
]
=
block
.
RawBlock
.
Hash
()
}
d
.
importLock
.
Lock
()
d
.
importQueue
=
hashes
d
.
importLock
.
Unlock
()
}
return
blocks
}
// Has checks if the downloader knows about a particular hash, meaning that its
...
...
@@ -255,9 +282,13 @@ func (d *Downloader) Cancel() bool {
}
d
.
cancelLock
.
Unlock
()
//
reset the queue
//
Reset the queue and import statistics
d
.
queue
.
Reset
()
d
.
importLock
.
Lock
()
d
.
importQueue
=
nil
d
.
importLock
.
Unlock
()
return
true
}
...
...
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