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
7ac24d55
Commit
7ac24d55
authored
Apr 28, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: seperated proccing mutex and getting mutex
parent
9f321174
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
42 deletions
+48
-42
block_processor.go
core/block_processor.go
+1
-1
chain_manager.go
core/chain_manager.go
+47
-41
No files found.
core/block_processor.go
View file @
7ac24d55
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
const
(
const
(
// must be bumped when consensus algorithm is changed, this forces the upgradedb
// must be bumped when consensus algorithm is changed, this forces the upgradedb
// command to be run (forces the blocks to be imported again using the new algorithm)
// command to be run (forces the blocks to be imported again using the new algorithm)
BlockChainVersion
=
3
BlockChainVersion
=
2
)
)
var
statelogger
=
logger
.
NewLogger
(
"BLOCK"
)
var
statelogger
=
logger
.
NewLogger
(
"BLOCK"
)
...
...
core/chain_manager.go
View file @
7ac24d55
...
@@ -76,6 +76,8 @@ type ChainManager struct {
...
@@ -76,6 +76,8 @@ type ChainManager struct {
// Last known total difficulty
// Last known total difficulty
mu
sync
.
RWMutex
mu
sync
.
RWMutex
tsmu
sync
.
RWMutex
tsmu
sync
.
RWMutex
insertMu
sync
.
Mutex
td
*
big
.
Int
td
*
big
.
Int
currentBlock
*
types
.
Block
currentBlock
*
types
.
Block
lastBlockHash
common
.
Hash
lastBlockHash
common
.
Hash
...
@@ -496,8 +498,8 @@ func (self *ChainManager) procFutureBlocks() {
...
@@ -496,8 +498,8 @@ func (self *ChainManager) procFutureBlocks() {
}
}
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
self
.
m
u
.
Lock
()
self
.
insertM
u
.
Lock
()
defer
self
.
m
u
.
Unlock
()
defer
self
.
insertM
u
.
Unlock
()
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var
(
var
(
...
@@ -546,6 +548,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -546,6 +548,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
block
.
Td
=
new
(
big
.
Int
)
.
Set
(
CalculateTD
(
block
,
self
.
GetBlock
(
block
.
ParentHash
())))
block
.
Td
=
new
(
big
.
Int
)
.
Set
(
CalculateTD
(
block
,
self
.
GetBlock
(
block
.
ParentHash
())))
self
.
mu
.
Lock
()
{
cblock
:=
self
.
currentBlock
cblock
:=
self
.
currentBlock
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// not in the canonical chain.
// not in the canonical chain.
...
@@ -591,6 +595,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -591,6 +595,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
queue
[
i
]
=
ChainSideEvent
{
block
,
logs
}
queue
[
i
]
=
ChainSideEvent
{
block
,
logs
}
queueEvent
.
sideCount
++
queueEvent
.
sideCount
++
}
}
}
self
.
mu
.
Unlock
()
stats
.
processed
++
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