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
3d497be9
Commit
3d497be9
authored
Apr 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: drop blocks with low TD
parent
6e1aa91a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
handler.go
eth/handler.go
+3
-3
peer.go
eth/peer.go
+4
-2
No files found.
eth/handler.go
View file @
3d497be9
...
...
@@ -36,6 +36,7 @@ pm.chainman.InsertChain(blocks)
import
(
"fmt"
"math/big"
"sync"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -273,12 +274,11 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if
self
.
chainman
.
HasBlock
(
hash
)
{
break
}
/* XXX unsure about this
/* XXX unsure about this
*/
if
self
.
chainman
.
Td
()
.
Cmp
(
request
.
TD
)
>
0
&&
new
(
big
.
Int
)
.
Add
(
request
.
Block
.
Number
(),
big
.
NewInt
(
7
))
.
Cmp
(
self
.
chainman
.
CurrentBlock
()
.
Number
())
<
0
{
glog.V(logger.Debug).Info
ln("dropped block", request.Block.Number(), "due to low TD"
, request.TD)
glog
.
V
(
logger
.
Debug
)
.
Info
f
(
"[%s] dropped block %v due to low TD %v
\n
"
,
p
.
id
,
request
.
Block
.
Number
()
,
request
.
TD
)
break
}
*/
// Attempt to insert the newly received by checking if the parent exists.
// if the parent exists we process the block and propagate to our peers
...
...
eth/peer.go
View file @
3d497be9
...
...
@@ -6,6 +6,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
"gopkg.in/fatih/set.v0"
)
...
...
@@ -85,12 +87,12 @@ func (p *peer) sendNewBlock(block *types.Block) error {
}
func
(
p
*
peer
)
requestHashes
(
from
common
.
Hash
)
error
{
p
.
Debugf
(
"fetching hashes (%d) %x...
\n
"
,
maxHashes
,
from
[
0
:
4
])
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"[%s] fetching hashes (%d) %x...
\n
"
,
p
.
id
,
maxHashes
,
from
[
:
4
])
return
p2p
.
Send
(
p
.
rw
,
GetBlockHashesMsg
,
getBlockHashesMsgData
{
from
,
maxHashes
})
}
func
(
p
*
peer
)
requestBlocks
(
hashes
[]
common
.
Hash
)
error
{
p
.
Debugf
(
"fetching %v blocks"
,
len
(
hashes
))
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"[%s] fetching %v blocks
\n
"
,
p
.
id
,
len
(
hashes
))
return
p2p
.
Send
(
p
.
rw
,
GetBlocksMsg
,
hashes
)
}
...
...
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