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
61db7a71
Commit
61db7a71
authored
Apr 11, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #695 from ethersphere/frontier/blockpool
bugfixes for headsection deadlocks
parents
f047699a
406feee5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
peers.go
blockpool/peers.go
+15
-7
No files found.
blockpool/peers.go
View file @
61db7a71
...
...
@@ -89,10 +89,12 @@ func (self *peers) newPeer(
peerError
:
peerError
,
currentBlockC
:
make
(
chan
*
types
.
Block
),
headSectionC
:
make
(
chan
*
section
),
switchC
:
make
(
chan
bool
),
bp
:
self
.
bp
,
idle
:
true
,
addToBlacklist
:
self
.
addToBlacklist
,
}
close
(
p
.
switchC
)
//! hack :((((
// at creation the peer is recorded in the peer pool
self
.
peers
[
id
]
=
p
return
...
...
@@ -153,7 +155,8 @@ func (self *peer) setChainInfo(td *big.Int, currentBlockHash common.Hash) {
func
(
self
*
peer
)
setChainInfoFromBlock
(
block
*
types
.
Block
)
(
td
*
big
.
Int
,
currentBlockHash
common
.
Hash
)
{
self
.
lock
.
Lock
()
defer
self
.
lock
.
Unlock
()
currentBlockC
:=
self
.
currentBlockC
switchC
:=
self
.
switchC
hash
:=
block
.
Hash
()
// this happens when block came in a newblock message but
// also if sent in a blockmsg (for instance, if we requested, only if we
...
...
@@ -162,15 +165,20 @@ func (self *peer) setChainInfoFromBlock(block *types.Block) (td *big.Int, curren
if
currentBlockHash
==
hash
&&
self
.
currentBlock
==
nil
{
// signal to head section process
plog
.
DebugDetailf
(
"AddBlock: head block %s for peer <%s> (head: %s) received
\n
"
,
hex
(
hash
),
self
.
id
,
hex
(
currentBlockHash
))
select
{
case
self
.
currentBlockC
<-
block
:
case
<-
self
.
switchC
:
}
return
self
.
td
,
currentBlockHash
td
=
self
.
td
}
else
{
plog
.
DebugDetailf
(
"AddBlock: head block %s for peer <%s> (head: %s) already known"
,
hex
(
hash
),
self
.
id
,
hex
(
currentBlockHash
))
return
nil
,
currentBlockHash
}
self
.
lock
.
Unlock
()
// this must be called without peerlock.
// peerlock held can halt the loop and block on select forever
if
td
!=
nil
{
select
{
case
currentBlockC
<-
block
:
case
<-
switchC
:
// peer is not best peer
}
}
return
}
// this will use the TD given by the first peer to update peer td, this helps second best peer selection
...
...
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