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
0d536734
Commit
0d536734
authored
Apr 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: adapted to new synchronous api of downloader's AddBlock
parent
c2c24b3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
downloader.go
eth/downloader/downloader.go
+0
-2
synchronous.go
eth/downloader/synchronous.go
+2
-0
handler.go
eth/handler.go
+12
-2
No files found.
eth/downloader/downloader.go
View file @
0d536734
...
...
@@ -173,8 +173,6 @@ out:
select
{
case
sync
:=
<-
d
.
syncCh
:
var
peer
*
peer
=
sync
.
peer
d
.
activePeer
=
peer
.
id
err
:=
d
.
getFromPeer
(
peer
,
sync
.
hash
,
sync
.
ignoreInitial
)
if
err
!=
nil
{
break
...
...
eth/downloader/synchronous.go
View file @
0d536734
...
...
@@ -50,6 +50,8 @@ func (d *Downloader) Synchronise() (types.Blocks, error) {
}
func
(
d
*
Downloader
)
getFromPeer
(
p
*
peer
,
hash
common
.
Hash
,
ignoreInitial
bool
)
error
{
d
.
activePeer
=
p
.
id
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"Synchronising with the network using:"
,
p
.
id
)
// Start the fetcher. This will block the update entirely
// interupts need to be send to the appropriate channels
...
...
eth/handler.go
View file @
0d536734
...
...
@@ -265,10 +265,12 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if
self
.
chainman
.
HasBlock
(
hash
)
{
break
}
if
self
.
chainman
.
Td
()
.
Cmp
(
request
.
TD
)
>
0
{
/* 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).Infoln("dropped block", request.Block.Number(), "due to low TD", 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
...
...
@@ -281,7 +283,15 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
}
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
}
else
{
self
.
downloader
.
AddBlock
(
p
.
id
,
request
.
Block
,
request
.
TD
)
// adding blocks is synchronous
go
func
()
{
err
:=
self
.
downloader
.
AddBlock
(
p
.
id
,
request
.
Block
,
request
.
TD
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"downloader err:"
,
err
)
return
}
self
.
BroadcastBlock
(
hash
,
request
.
Block
)
}()
}
default
:
return
errResp
(
ErrInvalidMsgCode
,
"%v"
,
msg
.
Code
)
...
...
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