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
eae09275
Commit
eae09275
authored
May 26, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: prevent crash when last block fails
parent
d74ee40c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
chain_manager.go
core/chain_manager.go
+16
-6
No files found.
core/chain_manager.go
View file @
eae09275
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"math/big"
"math/big"
"os"
"runtime"
"runtime"
"sync"
"sync"
"time"
"time"
...
@@ -233,14 +234,23 @@ func (bc *ChainManager) setLastState() {
...
@@ -233,14 +234,23 @@ func (bc *ChainManager) setLastState() {
data
,
_
:=
bc
.
blockDb
.
Get
([]
byte
(
"LastBlock"
))
data
,
_
:=
bc
.
blockDb
.
Get
([]
byte
(
"LastBlock"
))
if
len
(
data
)
!=
0
{
if
len
(
data
)
!=
0
{
block
:=
bc
.
GetBlock
(
common
.
BytesToHash
(
data
))
block
:=
bc
.
GetBlock
(
common
.
BytesToHash
(
data
))
bc
.
currentBlock
=
block
if
block
!=
nil
{
bc
.
lastBlockHash
=
block
.
Hash
()
bc
.
currentBlock
=
block
bc
.
lastBlockHash
=
block
.
Hash
()
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
}
else
{
// TODO CLEAN THIS UP TMP CODE
bc
.
td
=
common
.
BigD
(
bc
.
blockDb
.
LastKnownTD
())
block
=
bc
.
GetBlockByNumber
(
400000
)
if
block
==
nil
{
fmt
.
Println
(
"Fatal. LastBlock not found. Report this issue"
)
os
.
Exit
(
1
)
}
bc
.
currentBlock
=
block
bc
.
lastBlockHash
=
block
.
Hash
()
bc
.
insert
(
block
)
}
}
else
{
}
else
{
bc
.
Reset
()
bc
.
Reset
()
}
}
bc
.
td
=
bc
.
currentBlock
.
Td
bc
.
currentGasLimit
=
CalcGasLimit
(
bc
.
currentBlock
)
bc
.
currentGasLimit
=
CalcGasLimit
(
bc
.
currentBlock
)
if
glog
.
V
(
logger
.
Info
)
{
if
glog
.
V
(
logger
.
Info
)
{
...
@@ -471,7 +481,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
...
@@ -471,7 +481,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
}
}
func
(
bc
*
ChainManager
)
setTotalDifficulty
(
td
*
big
.
Int
)
{
func
(
bc
*
ChainManager
)
setTotalDifficulty
(
td
*
big
.
Int
)
{
bc
.
blockDb
.
Put
([]
byte
(
"LTD"
),
td
.
Bytes
())
//
bc.blockDb.Put([]byte("LTD"), td.Bytes())
bc
.
td
=
td
bc
.
td
=
td
}
}
...
...
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