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
d09ead54
Commit
d09ead54
authored
Jun 09, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: fix a data race in the hash announcement processing
parent
f8670771
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
sync.go
eth/sync.go
+18
-10
No files found.
eth/sync.go
View file @
d09ead54
...
...
@@ -109,17 +109,25 @@ func (pm *ProtocolManager) fetcher() {
// If any explicit fetches were replied to, import them
if
count
:=
len
(
explicit
);
count
>
0
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Importing %d explicitly fetched blocks"
,
count
)
// Create a closure with the retrieved blocks and origin peers
peers
:=
make
([]
*
peer
,
0
,
count
)
blocks
:=
make
([]
*
types
.
Block
,
0
,
count
)
for
_
,
block
:=
range
explicit
{
hash
:=
block
.
Hash
()
if
announce
:=
pending
[
hash
];
announce
!=
nil
{
peers
=
append
(
peers
,
announce
.
peer
)
blocks
=
append
(
blocks
,
block
)
delete
(
pending
,
hash
)
}
}
// Run the importer on a new thread
go
func
()
{
for
_
,
block
:=
range
explicit
{
hash
:=
block
.
Hash
()
// Make sure there's still something pending to import
if
announce
:=
pending
[
hash
];
announce
!=
nil
{
delete
(
pending
,
hash
)
if
err
:=
pm
.
importBlock
(
announce
.
peer
,
block
,
nil
);
err
!=
nil
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Failed to import explicitly fetched block: %v"
,
err
)
return
}
for
i
:=
0
;
i
<
len
(
blocks
);
i
++
{
if
err
:=
pm
.
importBlock
(
peers
[
i
],
blocks
[
i
],
nil
);
err
!=
nil
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Failed to import explicitly fetched block: %v"
,
err
)
return
}
}
}()
...
...
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