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
8595198c
Commit
8595198c
authored
Apr 30, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: delete blocks from queue
parent
15873faf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
downloader.go
eth/downloader/downloader.go
+14
-2
handler.go
eth/handler.go
+1
-1
No files found.
eth/downloader/downloader.go
View file @
8595198c
...
...
@@ -354,6 +354,11 @@ func (d *Downloader) AddHashes(id string, hashes []common.Hash) error {
return
fmt
.
Errorf
(
"received hashes from %s while active peer is %s"
,
id
,
d
.
activePeer
)
}
if
glog
.
V
(
logger
.
Detail
)
&&
len
(
hashes
)
!=
0
{
from
,
to
:=
hashes
[
0
],
hashes
[
len
(
hashes
)
-
1
]
glog
.
Infof
(
"adding %d (T=%d) hashes [ %x / %x ] from: %s
\n
"
,
len
(
hashes
),
d
.
queue
.
hashPool
.
Size
(),
from
[
:
4
],
to
[
:
4
],
id
)
}
d
.
hashCh
<-
hashes
return
nil
...
...
@@ -448,10 +453,17 @@ func (d *Downloader) process(peer *peer) error {
return
ErrBadPeer
}
blocks
=
blocks
[
max
:
]
// delete the blocks from the slice and let them be garbage collected
// without this slice trick the blocks would stay in memory until nil
// would be assigned to d.queue.blocks
copy
(
blocks
,
blocks
[
max
:
])
for
k
,
n
:=
len
(
blocks
)
-
max
,
len
(
blocks
);
k
<
n
;
k
++
{
blocks
[
k
]
=
nil
}
blocks
=
blocks
[
:
len
(
blocks
)
-
max
]
}
// This will allow the GC to remove the in memory blocks
if
len
(
blocks
)
==
0
{
d
.
queue
.
blocks
=
nil
}
else
{
...
...
eth/handler.go
View file @
8595198c
...
...
@@ -455,7 +455,7 @@ func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block)
for
_
,
peer
:=
range
peers
{
peer
.
sendNewBlock
(
block
)
}
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"broadcast block to"
,
len
(
peers
),
"peers. Total pro
pagation
time:"
,
time
.
Since
(
block
.
ReceivedAt
))
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"broadcast block to"
,
len
(
peers
),
"peers. Total pro
cessing
time:"
,
time
.
Since
(
block
.
ReceivedAt
))
}
// BroadcastTx will propagate the block to its connected peers. It will sort
...
...
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