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
8a3ce545
Commit
8a3ce545
authored
Mar 11, 2016
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2311 from obscuren/future-proc-fix
core: added future proc mutex lock
parents
08759b0a
558d18d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
blockchain.go
core/blockchain.go
+15
-14
No files found.
core/blockchain.go
View file @
8a3ce545
...
...
@@ -85,10 +85,9 @@ type BlockChain struct {
eventMux
*
event
.
TypeMux
genesisBlock
*
types
.
Block
mu
sync
.
RWMutex
chainmu
sync
.
RWMutex
tsmu
sync
.
RWMutex
procmu
sync
.
RWMutex
mu
sync
.
RWMutex
// global mutex for locking chain operations
chainmu
sync
.
RWMutex
// blockchain insertion lock
procmu
sync
.
RWMutex
// block processor lock
checkpoint
int
// checkpoint counts towards the new checkpoint
currentBlock
*
types
.
Block
// Current head of the block chain
...
...
@@ -99,15 +98,15 @@ type BlockChain struct {
blockCache
*
lru
.
Cache
// Cache for the most recent entire blocks
futureBlocks
*
lru
.
Cache
// future blocks are blocks added for later processing
quit
chan
struct
{}
running
int32
// running must be called automically
quit
chan
struct
{}
// blockchain quit channel
running
int32
// running must be called automically
// procInterrupt must be atomically called
procInterrupt
int32
// interrupt signaler for block processing
wg
sync
.
WaitGroup
procInterrupt
int32
// interrupt signaler for block processing
wg
sync
.
WaitGroup
// chain processing wait group for shutting down
pow
pow
.
PoW
processor
Processor
validator
Validator
processor
Processor
// block processor interface
validator
Validator
// block and state validator interface
}
// NewBlockChain returns a fully initialised block chain using information
...
...
@@ -567,10 +566,11 @@ func (bc *BlockChain) Stop() {
}
func
(
self
*
BlockChain
)
procFutureBlocks
()
{
blocks
:=
make
([]
*
types
.
Block
,
self
.
futureBlocks
.
Len
())
for
i
,
hash
:=
range
self
.
futureBlocks
.
Keys
()
{
block
,
_
:=
self
.
futureBlocks
.
Get
(
hash
)
blocks
[
i
]
=
block
.
(
*
types
.
Block
)
blocks
:=
make
([]
*
types
.
Block
,
0
,
self
.
futureBlocks
.
Len
())
for
_
,
hash
:=
range
self
.
futureBlocks
.
Keys
()
{
if
block
,
exist
:=
self
.
futureBlocks
.
Get
(
hash
);
exist
{
blocks
=
append
(
blocks
,
block
.
(
*
types
.
Block
))
}
}
if
len
(
blocks
)
>
0
{
types
.
BlockBy
(
types
.
Number
)
.
Sort
(
blocks
)
...
...
@@ -794,6 +794,7 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
if
err
:=
WriteBlock
(
self
.
chainDb
,
block
);
err
!=
nil
{
glog
.
Fatalf
(
"filed to write block contents: %v"
,
err
)
}
self
.
futureBlocks
.
Remove
(
block
.
Hash
())
return
...
...
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