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
9226369b
Commit
9226369b
authored
Jun 30, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/0.9.34-1' into develop
parents
b047f05e
d8fe64ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
chain_manager.go
core/chain_manager.go
+18
-15
worker.go
miner/worker.go
+1
-1
No files found.
core/chain_manager.go
View file @
9226369b
...
@@ -364,14 +364,12 @@ func (bc *ChainManager) insert(block *types.Block) {
...
@@ -364,14 +364,12 @@ func (bc *ChainManager) insert(block *types.Block) {
func
(
bc
*
ChainManager
)
write
(
block
*
types
.
Block
)
{
func
(
bc
*
ChainManager
)
write
(
block
*
types
.
Block
)
{
tstart
:=
time
.
Now
()
tstart
:=
time
.
Now
()
go
func
()
{
enc
,
_
:=
rlp
.
EncodeToBytes
((
*
types
.
StorageBlock
)(
block
))
enc
,
_
:=
rlp
.
EncodeToBytes
((
*
types
.
StorageBlock
)(
block
))
key
:=
append
(
blockHashPre
,
block
.
Hash
()
.
Bytes
()
...
)
key
:=
append
(
blockHashPre
,
block
.
Hash
()
.
Bytes
()
...
)
err
:=
bc
.
blockDb
.
Put
(
key
,
enc
)
err
:=
bc
.
blockDb
.
Put
(
key
,
enc
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatal
(
"db write fail:"
,
err
)
glog
.
Fatal
(
"db write fail:"
,
err
)
}
}
}()
if
glog
.
V
(
logger
.
Debug
)
{
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"wrote block #%v %s. Took %v
\n
"
,
block
.
Number
(),
common
.
PP
(
block
.
Hash
()
.
Bytes
()),
time
.
Since
(
tstart
))
glog
.
Infof
(
"wrote block #%v %s. Took %v
\n
"
,
block
.
Number
(),
common
.
PP
(
block
.
Hash
()
.
Bytes
()),
time
.
Since
(
tstart
))
...
@@ -555,7 +553,8 @@ const (
...
@@ -555,7 +553,8 @@ const (
sideStatTy
sideStatTy
)
)
func
(
self
*
ChainManager
)
WriteBlock
(
block
*
types
.
Block
)
(
status
writeStatus
,
err
error
)
{
// WriteBlock writes the block to the chain (or pending queue)
func
(
self
*
ChainManager
)
WriteBlock
(
block
*
types
.
Block
,
queued
bool
)
(
status
writeStatus
,
err
error
)
{
self
.
wg
.
Add
(
1
)
self
.
wg
.
Add
(
1
)
defer
self
.
wg
.
Done
()
defer
self
.
wg
.
Done
()
...
@@ -587,11 +586,15 @@ func (self *ChainManager) WriteBlock(block *types.Block) (status writeStatus, er
...
@@ -587,11 +586,15 @@ func (self *ChainManager) WriteBlock(block *types.Block) (status writeStatus, er
status
=
sideStatTy
status
=
sideStatTy
}
}
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
if
queued
{
// not in the canonical chain.
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
self
.
mu
.
Lock
()
// not in the canonical chain.
self
.
enqueueForWrite
(
block
)
self
.
mu
.
Lock
()
self
.
mu
.
Unlock
()
self
.
enqueueForWrite
(
block
)
self
.
mu
.
Unlock
()
}
else
{
self
.
write
(
block
)
}
// Delete from future blocks
// Delete from future blocks
self
.
futureBlocks
.
Remove
(
block
.
Hash
())
self
.
futureBlocks
.
Remove
(
block
.
Hash
())
...
@@ -693,7 +696,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
...
@@ -693,7 +696,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
txcount
+=
len
(
block
.
Transactions
())
txcount
+=
len
(
block
.
Transactions
())
// write the block to the chain and get the status
// write the block to the chain and get the status
status
,
err
:=
self
.
WriteBlock
(
block
)
status
,
err
:=
self
.
WriteBlock
(
block
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
i
,
err
return
i
,
err
}
}
...
...
miner/worker.go
View file @
9226369b
...
@@ -233,7 +233,7 @@ func (self *worker) wait() {
...
@@ -233,7 +233,7 @@ func (self *worker) wait() {
continue
continue
}
}
_
,
err
:=
self
.
chain
.
WriteBlock
(
block
)
_
,
err
:=
self
.
chain
.
WriteBlock
(
block
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"error writing block to chain"
,
err
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"error writing block to chain"
,
err
)
continue
continue
...
...
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