good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
dd1791c9
Commit
dd1791c9
authored
Apr 2, 2015
by
Viktor Trón
Browse files
Options
Downloads
Patches
Plain Diff
proper locking to prevent close of closed channel crash when multiple mining peers compete
parent
607fc788
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
blockpool/peers.go
+7
-3
7 additions, 3 deletions
blockpool/peers.go
with
7 additions
and
3 deletions
blockpool/peers.go
+
7
−
3
View file @
dd1791c9
...
@@ -219,6 +219,7 @@ func (self *peers) addPeer(
...
@@ -219,6 +219,7 @@ func (self *peers) addPeer(
return
return
}
}
self
.
lock
.
Lock
()
self
.
lock
.
Lock
()
defer
self
.
lock
.
Unlock
()
p
,
found
:=
self
.
peers
[
id
]
p
,
found
:=
self
.
peers
[
id
]
if
found
{
if
found
{
// when called on an already connected peer, it means a newBlockMsg is received
// when called on an already connected peer, it means a newBlockMsg is received
...
@@ -243,7 +244,6 @@ func (self *peers) addPeer(
...
@@ -243,7 +244,6 @@ func (self *peers) addPeer(
plog
.
Debugf
(
"addPeer: add new peer <%v> with td %v and current block %s"
,
id
,
td
,
hex
(
currentBlockHash
))
plog
.
Debugf
(
"addPeer: add new peer <%v> with td %v and current block %s"
,
id
,
td
,
hex
(
currentBlockHash
))
}
}
self
.
lock
.
Unlock
()
// check if peer's current head block is known
// check if peer's current head block is known
if
self
.
bp
.
hasBlock
(
currentBlockHash
)
{
if
self
.
bp
.
hasBlock
(
currentBlockHash
)
{
...
@@ -269,7 +269,10 @@ func (self *peers) addPeer(
...
@@ -269,7 +269,10 @@ func (self *peers) addPeer(
}
else
{
}
else
{
// baseline is our own TD
// baseline is our own TD
currentTD
:=
self
.
bp
.
getTD
()
currentTD
:=
self
.
bp
.
getTD
()
if
self
.
best
!=
nil
{
bestpeer
:=
self
.
best
if
bestpeer
!=
nil
{
bestpeer
.
lock
.
Lock
()
defer
bestpeer
.
lock
.
Unlock
()
currentTD
=
self
.
best
.
td
currentTD
=
self
.
best
.
td
}
}
if
td
.
Cmp
(
currentTD
)
>
0
{
if
td
.
Cmp
(
currentTD
)
>
0
{
...
@@ -277,11 +280,12 @@ func (self *peers) addPeer(
...
@@ -277,11 +280,12 @@ func (self *peers) addPeer(
self
.
status
.
bestPeers
[
p
.
id
]
++
self
.
status
.
bestPeers
[
p
.
id
]
++
self
.
status
.
lock
.
Unlock
()
self
.
status
.
lock
.
Unlock
()
plog
.
Debugf
(
"addPeer: peer <%v> (td: %v > current td %v) promoted best peer"
,
id
,
td
,
currentTD
)
plog
.
Debugf
(
"addPeer: peer <%v> (td: %v > current td %v) promoted best peer"
,
id
,
td
,
currentTD
)
self
.
bp
.
switchPeer
(
self
.
best
,
p
)
self
.
bp
.
switchPeer
(
best
peer
,
p
)
self
.
best
=
p
self
.
best
=
p
best
=
true
best
=
true
}
}
}
}
return
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment