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
f2a2b2ac
Commit
f2a2b2ac
authored
May 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: put back hashes on block overflow error
parent
493181ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
queue.go
eth/downloader/queue.go
+14
-19
No files found.
eth/downloader/queue.go
View file @
f2a2b2ac
package
downloader
import
(
"fmt"
"math"
"sync"
"time"
...
...
@@ -102,17 +103,6 @@ func (c *queue) has(hash common.Hash) bool {
return
c
.
hashPool
.
Has
(
hash
)
||
c
.
fetchPool
.
Has
(
hash
)
||
c
.
blockHashes
.
Has
(
hash
)
}
func
(
c
*
queue
)
addBlock
(
id
string
,
block
*
types
.
Block
)
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
// when adding a block make sure it doesn't already exist
if
!
c
.
blockHashes
.
Has
(
block
.
Hash
())
{
c
.
hashPool
.
Remove
(
block
.
Hash
())
c
.
blocks
=
append
(
c
.
blocks
,
block
)
}
}
func
(
c
*
queue
)
getBlock
(
hash
common
.
Hash
)
*
types
.
Block
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
...
...
@@ -130,7 +120,7 @@ func (c *queue) getBlock(hash common.Hash) *types.Block {
}
// deliver delivers a chunk to the queue that was requested of the peer
func
(
c
*
queue
)
deliver
(
id
string
,
blocks
[]
*
types
.
Block
)
error
{
func
(
c
*
queue
)
deliver
(
id
string
,
blocks
[]
*
types
.
Block
)
(
err
error
)
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
...
...
@@ -145,25 +135,30 @@ func (c *queue) deliver(id string, blocks []*types.Block) error {
chunk
.
peer
.
ignored
.
Merge
(
chunk
.
hashes
)
}
// seperate the blocks and the hashes
blockHashes
:=
chunk
.
fetchedHashes
(
blocks
)
// merge block hashes
c
.
blockHashes
.
Merge
(
blockHashes
)
// Add the blocks
for
_
,
block
:=
range
blocks
{
for
i
,
block
:=
range
blocks
{
// See (1) for future limitation
n
:=
int
(
block
.
NumberU64
())
-
c
.
blockOffset
if
n
>
len
(
c
.
blocks
)
||
n
<
0
{
return
errBlockNumberOverflow
// set the error and set the blocks which could be processed
// abort the rest of the blocks (FIXME this could be improved)
err
=
fmt
.
Errorf
(
"received block which overflow (N=%v O=%v)"
,
block
.
Number
(),
c
.
blockOffset
)
blocks
=
blocks
[
:
i
]
break
}
c
.
blocks
[
n
]
=
block
}
// seperate the blocks and the hashes
blockHashes
:=
chunk
.
fetchedHashes
(
blocks
)
// merge block hashes
c
.
blockHashes
.
Merge
(
blockHashes
)
// Add back whatever couldn't be delivered
c
.
hashPool
.
Merge
(
chunk
.
hashes
)
// Remove the hashes from the fetch pool
c
.
fetchPool
.
Separate
(
chunk
.
hashes
)
}
return
nil
return
}
func
(
c
*
queue
)
alloc
(
offset
,
size
int
)
{
...
...
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