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
511bf8f1
Unverified
Commit
511bf8f1
authored
Sep 01, 2022
by
Péter Szilágyi
Committed by
GitHub
Sep 01, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25651 from holiman/fix_snapqueue
eth/protocols/snap: fix problems due to idle-but-busy peers
parents
d46184c9
dafa40e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
35 deletions
+55
-35
sync.go
eth/protocols/snap/sync.go
+55
-35
No files found.
eth/protocols/snap/sync.go
View file @
511bf8f1
...
...
@@ -2248,14 +2248,18 @@ func (s *Syncer) OnAccounts(peer SyncPeer, id uint64, hashes []common.Hash, acco
// Whether or not the response is valid, we can mark the peer as idle and
// notify the scheduler to assign a new task. If the response is invalid,
// we'll drop the peer in a bit.
defer
func
()
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
accountIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
}()
s
.
lock
.
Lock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
accountIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
// Ensure the response is for a valid request
req
,
ok
:=
s
.
accountReqs
[
id
]
if
!
ok
{
...
...
@@ -2360,14 +2364,18 @@ func (s *Syncer) onByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) error
// Whether or not the response is valid, we can mark the peer as idle and
// notify the scheduler to assign a new task. If the response is invalid,
// we'll drop the peer in a bit.
defer
func
()
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
bytecodeIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
}()
s
.
lock
.
Lock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
bytecodeIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
// Ensure the response is for a valid request
req
,
ok
:=
s
.
bytecodeReqs
[
id
]
if
!
ok
{
...
...
@@ -2469,14 +2477,18 @@ func (s *Syncer) OnStorage(peer SyncPeer, id uint64, hashes [][]common.Hash, slo
// Whether or not the response is valid, we can mark the peer as idle and
// notify the scheduler to assign a new task. If the response is invalid,
// we'll drop the peer in a bit.
defer
func
()
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
storageIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
}()
s
.
lock
.
Lock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
storageIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
// Ensure the response is for a valid request
req
,
ok
:=
s
.
storageReqs
[
id
]
if
!
ok
{
...
...
@@ -2596,14 +2608,18 @@ func (s *Syncer) OnTrieNodes(peer SyncPeer, id uint64, trienodes [][]byte) error
// Whether or not the response is valid, we can mark the peer as idle and
// notify the scheduler to assign a new task. If the response is invalid,
// we'll drop the peer in a bit.
defer
func
()
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
trienodeHealIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
}()
s
.
lock
.
Lock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
trienodeHealIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
// Ensure the response is for a valid request
req
,
ok
:=
s
.
trienodeHealReqs
[
id
]
if
!
ok
{
...
...
@@ -2691,14 +2707,18 @@ func (s *Syncer) onHealByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) e
// Whether or not the response is valid, we can mark the peer as idle and
// notify the scheduler to assign a new task. If the response is invalid,
// we'll drop the peer in a bit.
defer
func
()
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
bytecodeHealIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
}()
s
.
lock
.
Lock
()
if
_
,
ok
:=
s
.
peers
[
peer
.
ID
()];
ok
{
s
.
bytecodeHealIdlers
[
peer
.
ID
()]
=
struct
{}{}
}
select
{
case
s
.
update
<-
struct
{}{}
:
default
:
}
// Ensure the response is for a valid request
req
,
ok
:=
s
.
bytecodeHealReqs
[
id
]
if
!
ok
{
...
...
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