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
a9db1ee8
Commit
a9db1ee8
authored
Nov 04, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced to return the td and throw a specific error on TD
parent
699dcaf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
chain_manager.go
chain/chain_manager.go
+3
-6
error.go
chain/error.go
+12
-0
No files found.
chain/chain_manager.go
View file @
a9db1ee8
...
@@ -319,10 +319,7 @@ func (self *ChainManager) InsertChain(chain *BlockChain) {
...
@@ -319,10 +319,7 @@ func (self *ChainManager) InsertChain(chain *BlockChain) {
}
}
}
}
func
(
self
*
ChainManager
)
TestChain
(
chain
*
BlockChain
)
(
i
int
,
err
error
)
{
func
(
self
*
ChainManager
)
TestChain
(
chain
*
BlockChain
)
(
td
*
big
.
Int
,
err
error
)
{
var
(
td
*
big
.
Int
)
for
e
:=
chain
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
for
e
:=
chain
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
var
(
var
(
l
=
e
.
Value
.
(
*
link
)
l
=
e
.
Value
.
(
*
link
)
...
@@ -355,9 +352,9 @@ func (self *ChainManager) TestChain(chain *BlockChain) (i int, err error) {
...
@@ -355,9 +352,9 @@ func (self *ChainManager) TestChain(chain *BlockChain) (i int, err error) {
}
}
if
td
.
Cmp
(
self
.
TD
)
<=
0
{
if
td
.
Cmp
(
self
.
TD
)
<=
0
{
err
=
fmt
.
Errorf
(
"incoming chain has a lower or equal TD (%v <= %v)"
,
td
,
self
.
TD
)
err
=
&
TDError
{
td
,
self
.
TD
}
return
return
}
}
return
i
,
nil
return
}
}
chain/error.go
View file @
a9db1ee8
...
@@ -114,3 +114,15 @@ func IsOutOfGasErr(err error) bool {
...
@@ -114,3 +114,15 @@ func IsOutOfGasErr(err error) bool {
return
ok
return
ok
}
}
type
TDError
struct
{
a
,
b
*
big
.
Int
}
func
(
self
*
TDError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"incoming chain has a lower or equal TD (%v <= %v)"
,
self
.
a
,
self
.
b
)
}
func
IsTDError
(
e
error
)
bool
{
_
,
ok
:=
err
.
(
*
TDError
)
return
ok
}
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