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
be253963
Commit
be253963
authored
Apr 09, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate lock for blacklist
parent
a009132c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
peers.go
blockpool/peers.go
+6
-3
No files found.
blockpool/peers.go
View file @
be253963
...
...
@@ -57,7 +57,8 @@ type peer struct {
// peers is the component keeping a record of peers in a hashmap
//
type
peers
struct
{
lock
sync
.
RWMutex
lock
sync
.
RWMutex
bllock
sync
.
Mutex
bp
*
BlockPool
errors
*
errs
.
Errors
...
...
@@ -109,13 +110,15 @@ func (self *peers) peerError(id string, code int, format string, params ...inter
// record time of offence in blacklist to implement suspension for PeerSuspensionInterval
func
(
self
*
peers
)
addToBlacklist
(
id
string
)
{
self
.
lock
.
Lock
()
defer
self
.
lock
.
Unlock
()
self
.
bl
lock
.
Lock
()
defer
self
.
bl
lock
.
Unlock
()
self
.
blacklist
[
id
]
=
time
.
Now
()
}
// suspended checks if peer is still suspended, caller should hold peers.lock
func
(
self
*
peers
)
suspended
(
id
string
)
(
s
bool
)
{
self
.
bllock
.
Lock
()
defer
self
.
bllock
.
Unlock
()
if
suspendedAt
,
ok
:=
self
.
blacklist
[
id
];
ok
{
if
s
=
suspendedAt
.
Add
(
self
.
bp
.
Config
.
PeerSuspensionInterval
)
.
After
(
time
.
Now
());
!
s
{
// no longer suspended, delete entry
...
...
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