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
15873faf
Commit
15873faf
authored
Apr 30, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: added a wait group to chain manager for graceful shutdown
parent
e4dba368
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
chain_manager.go
core/chain_manager.go
+8
-0
backend.go
eth/backend.go
+1
-0
No files found.
core/chain_manager.go
View file @
15873faf
...
...
@@ -93,6 +93,7 @@ type ChainManager struct {
futureBlocks
*
BlockCache
quit
chan
struct
{}
wg
sync
.
WaitGroup
}
func
NewChainManager
(
blockDb
,
stateDb
common
.
Database
,
mux
*
event
.
TypeMux
)
*
ChainManager
{
...
...
@@ -482,6 +483,10 @@ func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error) {
func
(
bc
*
ChainManager
)
Stop
()
{
close
(
bc
.
quit
)
bc
.
wg
.
Wait
()
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Chain manager stopped"
)
}
type
queueEvent
struct
{
...
...
@@ -504,6 +509,9 @@ func (self *ChainManager) procFutureBlocks() {
// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned
// it will return the index number of the failing block as well an error describing what went wrong (for possible errors see core/errors.go).
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
(
int
,
error
)
{
self
.
wg
.
Add
(
1
)
defer
self
.
wg
.
Done
()
// 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
))
...
...
eth/backend.go
View file @
15873faf
...
...
@@ -454,6 +454,7 @@ func (self *Ethereum) SuggestPeer(nodeURL string) error {
func
(
s
*
Ethereum
)
Stop
()
{
s
.
txSub
.
Unsubscribe
()
// quits txBroadcastLoop
s
.
chainManager
.
Stop
()
s
.
protocolManager
.
Stop
()
s
.
txPool
.
Stop
()
s
.
eventMux
.
Stop
()
...
...
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