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
0e2bc231
Commit
0e2bc231
authored
Apr 08, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uncomment future block TD check, add test for skipping TD check on future block
parent
e55747a0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
9 deletions
+46
-9
blockpool.go
blockpool/blockpool.go
+4
-4
blockpool_util_test.go
blockpool/blockpool_util_test.go
+1
-1
errors_test.go
blockpool/errors_test.go
+39
-2
peers.go
blockpool/peers.go
+2
-2
No files found.
blockpool/blockpool.go
View file @
0e2bc231
...
...
@@ -790,10 +790,10 @@ func (self *BlockPool) checkTD(nodes ...*node) {
if
n
.
td
!=
nil
&&
!
n
.
block
.
Queued
()
{
plog
.
DebugDetailf
(
"peer td %v =?= block td %v"
,
n
.
td
,
n
.
block
.
Td
)
if
n
.
td
.
Cmp
(
n
.
block
.
Td
)
!=
0
{
//
self.peers.peerError(n.blockBy, ErrIncorrectTD, "on block %x", n.hash)
//
self.status.lock.Lock()
//
self.status.badPeers[n.blockBy]++
//
self.status.lock.Unlock()
self
.
peers
.
peerError
(
n
.
blockBy
,
ErrIncorrectTD
,
"on block %x"
,
n
.
hash
)
self
.
status
.
lock
.
Lock
()
self
.
status
.
badPeers
[
n
.
blockBy
]
++
self
.
status
.
lock
.
Unlock
()
}
}
}
...
...
blockpool/blockpool_util_test.go
View file @
0e2bc231
...
...
@@ -87,7 +87,7 @@ func (self *blockPoolTester) insertChain(blocks types.Blocks) error {
var
ok
bool
for
_
,
block
:=
range
blocks
{
child
=
self
.
hashPool
.
HashesToIndexes
([]
common
.
Hash
{
block
.
Hash
()})[
0
]
var
td
int
td
:=
child
if
self
.
tds
!=
nil
{
td
,
ok
=
self
.
tds
[
child
]
}
...
...
blockpool/errors_test.go
View file @
0e2bc231
...
...
@@ -128,8 +128,6 @@ func TestErrInsufficientChainInfo(t *testing.T) {
}
func
TestIncorrectTD
(
t
*
testing
.
T
)
{
t
.
Skip
()
// @zelig this one requires fixing for the TD
test
.
LogInit
()
_
,
blockPool
,
blockPoolTester
:=
newTestBlockPool
(
t
)
blockPoolTester
.
blockChain
[
0
]
=
nil
...
...
@@ -156,6 +154,45 @@ func TestIncorrectTD(t *testing.T) {
}
}
func
TestSkipIncorrectTDonFutureBlocks
(
t
*
testing
.
T
)
{
// t.Skip() // @zelig this one requires fixing for the TD
test
.
LogInit
()
_
,
blockPool
,
blockPoolTester
:=
newTestBlockPool
(
t
)
blockPoolTester
.
blockChain
[
0
]
=
nil
blockPoolTester
.
initRefBlockChain
(
3
)
blockPool
.
insertChain
=
func
(
blocks
types
.
Blocks
)
error
{
err
:=
blockPoolTester
.
insertChain
(
blocks
)
if
err
==
nil
{
for
_
,
block
:=
range
blocks
{
if
block
.
Td
.
Cmp
(
common
.
Big3
)
==
0
{
block
.
Td
=
common
.
Big3
block
.
SetQueued
(
true
)
break
}
}
}
return
err
}
blockPool
.
Start
()
peer1
:=
blockPoolTester
.
newPeer
(
"peer1"
,
3
,
3
)
peer1
.
AddPeer
()
go
peer1
.
serveBlocks
(
2
,
3
)
go
peer1
.
serveBlockHashes
(
3
,
2
,
1
,
0
)
peer1
.
serveBlocks
(
0
,
1
,
2
)
blockPool
.
Wait
(
waitTimeout
)
blockPool
.
Stop
()
blockPoolTester
.
refBlockChain
[
3
]
=
[]
int
{}
blockPoolTester
.
checkBlockChain
(
blockPoolTester
.
refBlockChain
)
if
len
(
peer1
.
peerErrors
)
>
0
{
t
.
Errorf
(
"expected no error, got %v (1 of %v)"
,
peer1
.
peerErrors
[
0
],
len
(
peer1
.
peerErrors
))
}
}
func
TestPeerSuspension
(
t
*
testing
.
T
)
{
test
.
LogInit
()
_
,
blockPool
,
blockPoolTester
:=
newTestBlockPool
(
t
)
...
...
blockpool/peers.go
View file @
0e2bc231
...
...
@@ -473,8 +473,8 @@ func (self *peer) getBlockHashes() bool {
// XXX added currentBlock check (?)
if
self
.
currentBlock
!=
nil
&&
self
.
currentBlock
.
Td
!=
nil
&&
!
self
.
currentBlock
.
Queued
()
{
if
self
.
td
.
Cmp
(
self
.
currentBlock
.
Td
)
!=
0
{
//
self.addError(ErrIncorrectTD, "on block %x", self.currentBlockHash)
//
self.bp.status.badPeers[self.id]++
self
.
addError
(
ErrIncorrectTD
,
"on block %x"
,
self
.
currentBlockHash
)
self
.
bp
.
status
.
badPeers
[
self
.
id
]
++
}
}
headKey
:=
self
.
parentHash
...
...
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