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
1100e8ba
Commit
1100e8ba
authored
Apr 09, 2018
by
gary rong
Committed by
Felix Lange
Apr 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: flush state sync data before exit (#16280)
parent
0fac705e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
statesync.go
eth/downloader/statesync.go
+13
-5
sync.go
trie/sync.go
+1
-1
No files found.
eth/downloader/statesync.go
View file @
1100e8ba
...
@@ -274,15 +274,21 @@ func (s *stateSync) Cancel() error {
...
@@ -274,15 +274,21 @@ func (s *stateSync) Cancel() error {
// receive data from peers, rather those are buffered up in the downloader and
// receive data from peers, rather those are buffered up in the downloader and
// pushed here async. The reason is to decouple processing from data receipt
// pushed here async. The reason is to decouple processing from data receipt
// and timeouts.
// and timeouts.
func
(
s
*
stateSync
)
loop
()
error
{
func
(
s
*
stateSync
)
loop
()
(
err
error
)
{
// Listen for new peer events to assign tasks to them
// Listen for new peer events to assign tasks to them
newPeer
:=
make
(
chan
*
peerConnection
,
1024
)
newPeer
:=
make
(
chan
*
peerConnection
,
1024
)
peerSub
:=
s
.
d
.
peers
.
SubscribeNewPeers
(
newPeer
)
peerSub
:=
s
.
d
.
peers
.
SubscribeNewPeers
(
newPeer
)
defer
peerSub
.
Unsubscribe
()
defer
peerSub
.
Unsubscribe
()
defer
func
()
{
cerr
:=
s
.
commit
(
true
)
if
err
==
nil
{
err
=
cerr
}
}()
// Keep assigning new tasks until the sync completes or aborts
// Keep assigning new tasks until the sync completes or aborts
for
s
.
sched
.
Pending
()
>
0
{
for
s
.
sched
.
Pending
()
>
0
{
if
err
:
=
s
.
commit
(
false
);
err
!=
nil
{
if
err
=
s
.
commit
(
false
);
err
!=
nil
{
return
err
return
err
}
}
s
.
assignTasks
()
s
.
assignTasks
()
...
@@ -307,14 +313,14 @@ func (s *stateSync) loop() error {
...
@@ -307,14 +313,14 @@ func (s *stateSync) loop() error {
s
.
d
.
dropPeer
(
req
.
peer
.
id
)
s
.
d
.
dropPeer
(
req
.
peer
.
id
)
}
}
// Process all the received blobs and check for stale delivery
// Process all the received blobs and check for stale delivery
if
err
:
=
s
.
process
(
req
);
err
!=
nil
{
if
err
=
s
.
process
(
req
);
err
!=
nil
{
log
.
Warn
(
"Node data write error"
,
"err"
,
err
)
log
.
Warn
(
"Node data write error"
,
"err"
,
err
)
return
err
return
err
}
}
req
.
peer
.
SetNodeDataIdle
(
len
(
req
.
response
))
req
.
peer
.
SetNodeDataIdle
(
len
(
req
.
response
))
}
}
}
}
return
s
.
commit
(
true
)
return
nil
}
}
func
(
s
*
stateSync
)
commit
(
force
bool
)
error
{
func
(
s
*
stateSync
)
commit
(
force
bool
)
error
{
...
@@ -323,7 +329,9 @@ func (s *stateSync) commit(force bool) error {
...
@@ -323,7 +329,9 @@ func (s *stateSync) commit(force bool) error {
}
}
start
:=
time
.
Now
()
start
:=
time
.
Now
()
b
:=
s
.
d
.
stateDB
.
NewBatch
()
b
:=
s
.
d
.
stateDB
.
NewBatch
()
s
.
sched
.
Commit
(
b
)
if
written
,
err
:=
s
.
sched
.
Commit
(
b
);
written
==
0
||
err
!=
nil
{
return
err
}
if
err
:=
b
.
Write
();
err
!=
nil
{
if
err
:=
b
.
Write
();
err
!=
nil
{
return
fmt
.
Errorf
(
"DB write error: %v"
,
err
)
return
fmt
.
Errorf
(
"DB write error: %v"
,
err
)
}
}
...
...
trie/sync.go
View file @
1100e8ba
...
@@ -212,7 +212,7 @@ func (s *TrieSync) Process(results []SyncResult) (bool, int, error) {
...
@@ -212,7 +212,7 @@ func (s *TrieSync) Process(results []SyncResult) (bool, int, error) {
}
}
// Commit flushes the data stored in the internal membatch out to persistent
// Commit flushes the data stored in the internal membatch out to persistent
// storage, returning th
e
number of items written and any occurred error.
// storage, returning th
e
number of items written and any occurred error.
func
(
s
*
TrieSync
)
Commit
(
dbw
ethdb
.
Putter
)
(
int
,
error
)
{
func
(
s
*
TrieSync
)
Commit
(
dbw
ethdb
.
Putter
)
(
int
,
error
)
{
// Dump the membatch into a database dbw
// Dump the membatch into a database dbw
for
i
,
key
:=
range
s
.
membatch
.
order
{
for
i
,
key
:=
range
s
.
membatch
.
order
{
...
...
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