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
516f49c8
Commit
516f49c8
authored
Apr 23, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: cleanup
parent
b6ec1c72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
5 deletions
+1
-5
handler.go
eth/handler.go
+1
-5
No files found.
eth/handler.go
View file @
516f49c8
...
@@ -276,7 +276,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -276,7 +276,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
return
errResp
(
ErrDecode
,
"block validation %v: %v"
,
msg
,
err
)
return
errResp
(
ErrDecode
,
"block validation %v: %v"
,
msg
,
err
)
}
}
hash
:=
request
.
Block
.
Hash
()
hash
:=
request
.
Block
.
Hash
()
// Add the block hash as a known hash to the peer. This will later be used to det
i
rmine
// Add the block hash as a known hash to the peer. This will later be used to det
e
rmine
// who should receive this.
// who should receive this.
p
.
blockHashes
.
Add
(
hash
)
p
.
blockHashes
.
Add
(
hash
)
...
@@ -296,7 +296,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -296,7 +296,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if
self
.
chainman
.
HasBlock
(
hash
)
{
if
self
.
chainman
.
HasBlock
(
hash
)
{
break
break
}
}
/* 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
{
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
)
.
Infof
(
"[%s] dropped block %v due to low TD %v
\n
"
,
p
.
id
,
request
.
Block
.
Number
(),
request
.
TD
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"[%s] dropped block %v due to low TD %v
\n
"
,
p
.
id
,
request
.
Block
.
Number
(),
request
.
TD
)
break
break
...
@@ -305,14 +304,12 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -305,14 +304,12 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
// Attempt to insert the newly received by checking if the parent exists.
// 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
// if the parent exists we process the block and propagate to our peers
// if the parent does not exists we delegate to the downloader.
// if the parent does not exists we delegate to the downloader.
// NOTE we can reduce chatter by dropping blocks with Td < currentTd
if
self
.
chainman
.
HasBlock
(
request
.
Block
.
ParentHash
())
{
if
self
.
chainman
.
HasBlock
(
request
.
Block
.
ParentHash
())
{
if
err
:=
self
.
chainman
.
InsertChain
(
types
.
Blocks
{
request
.
Block
});
err
!=
nil
{
if
err
:=
self
.
chainman
.
InsertChain
(
types
.
Blocks
{
request
.
Block
});
err
!=
nil
{
// handle error
// handle error
return
nil
return
nil
}
}
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
}
else
{
}
else
{
// adding blocks is synchronous
// adding blocks is synchronous
go
func
()
{
go
func
()
{
...
@@ -322,7 +319,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
...
@@ -322,7 +319,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
return
return
}
}
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
}()
}()
}
}
default
:
default
:
...
...
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