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
27782bba
Commit
27782bba
authored
May 16, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: global chain insert lock
parent
ad990895
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
44 deletions
+43
-44
chain_manager.go
core/chain_manager.go
+43
-44
No files found.
core/chain_manager.go
View file @
27782bba
...
...
@@ -84,6 +84,7 @@ type ChainManager struct {
genesisBlock
*
types
.
Block
// Last known total difficulty
mu
sync
.
RWMutex
chainmu
sync
.
RWMutex
tsmu
sync
.
RWMutex
td
*
big
.
Int
...
...
@@ -518,6 +519,9 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
self
.
wg
.
Add
(
1
)
defer
self
.
wg
.
Done
()
self
.
chainmu
.
Lock
()
defer
self
.
chainmu
.
Unlock
()
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var
(
queue
=
make
([]
interface
{},
len
(
chain
))
...
...
@@ -542,7 +546,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
continue
}
block
.
Td
=
new
(
big
.
Int
)
// Do not penelise on future block. We'll need a block queue eventually that will queue
// future block for future use
if
err
==
BlockFutureErr
{
...
...
@@ -568,8 +571,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
return
i
,
err
}
self
.
mu
.
Lock
()
{
cblock
:=
self
.
currentBlock
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// not in the canonical chain.
...
...
@@ -614,8 +615,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
queueEvent
.
sideCount
++
}
self
.
futureBlocks
.
Delete
(
block
.
Hash
())
}
self
.
mu
.
Unlock
()
stats
.
processed
++
...
...
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