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
ebf2aabd
Commit
ebf2aabd
authored
Jun 09, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix up a deadlock caused by double locking
parent
ff84352f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
chain_manager.go
core/chain_manager.go
+5
-8
No files found.
core/chain_manager.go
View file @
ebf2aabd
...
@@ -381,9 +381,6 @@ func (bc *ChainManager) insert(block *types.Block) {
...
@@ -381,9 +381,6 @@ func (bc *ChainManager) insert(block *types.Block) {
bc
.
blockDb
.
Put
(
key
,
block
.
Hash
()
.
Bytes
())
bc
.
blockDb
.
Put
(
key
,
block
.
Hash
()
.
Bytes
())
bc
.
blockDb
.
Put
([]
byte
(
"LastBlock"
),
block
.
Hash
()
.
Bytes
())
bc
.
blockDb
.
Put
([]
byte
(
"LastBlock"
),
block
.
Hash
()
.
Bytes
())
bc
.
mu
.
Lock
()
defer
bc
.
mu
.
Unlock
()
bc
.
currentBlock
=
block
bc
.
currentBlock
=
block
bc
.
lastBlockHash
=
block
.
Hash
()
bc
.
lastBlockHash
=
block
.
Hash
()
}
}
...
@@ -488,10 +485,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
...
@@ -488,10 +485,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
}
}
func
(
bc
*
ChainManager
)
setTotalDifficulty
(
td
*
big
.
Int
)
{
func
(
bc
*
ChainManager
)
setTotalDifficulty
(
td
*
big
.
Int
)
{
bc
.
mu
.
Lock
()
bc
.
td
=
new
(
big
.
Int
)
.
Set
(
td
)
defer
bc
.
mu
.
Unlock
()
bc
.
td
.
Set
(
td
)
}
}
func
(
self
*
ChainManager
)
CalcTotalDiff
(
block
*
types
.
Block
)
(
*
big
.
Int
,
error
)
{
func
(
self
*
ChainManager
)
CalcTotalDiff
(
block
*
types
.
Block
)
(
*
big
.
Int
,
error
)
{
...
@@ -546,6 +540,9 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
...
@@ -546,6 +540,9 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
self
.
wg
.
Add
(
1
)
self
.
wg
.
Add
(
1
)
defer
self
.
wg
.
Done
()
defer
self
.
wg
.
Done
()
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
self
.
chainmu
.
Lock
()
self
.
chainmu
.
Lock
()
defer
self
.
chainmu
.
Unlock
()
defer
self
.
chainmu
.
Unlock
()
...
@@ -628,7 +625,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
...
@@ -628,7 +625,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
cblock
:=
self
.
currentBlock
cblock
:=
self
.
currentBlock
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
if
block
.
Td
.
Cmp
(
self
.
Td
()
)
>
0
{
if
block
.
Td
.
Cmp
(
self
.
td
)
>
0
{
// chain fork
// chain fork
if
block
.
ParentHash
()
!=
cblock
.
Hash
()
{
if
block
.
ParentHash
()
!=
cblock
.
Hash
()
{
// during split we merge two different chains and create the new canonical chain
// during split we merge two different chains and create the new canonical chain
...
...
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