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
e51eeb81
Commit
e51eeb81
authored
Dec 15, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: fix #2076, where end of hash query was interpreted number query
parent
b9aedeab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
handler.go
eth/handler.go
+3
-1
handler_test.go
eth/handler_test.go
+20
-0
No files found.
eth/handler.go
View file @
e51eeb81
...
...
@@ -372,6 +372,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
if
err
:=
msg
.
Decode
(
&
query
);
err
!=
nil
{
return
errResp
(
ErrDecode
,
"%v: %v"
,
msg
,
err
)
}
hashMode
:=
query
.
Origin
.
Hash
!=
(
common
.
Hash
{})
// Gather headers until the fetch or network limits is reached
var
(
bytes
common
.
StorageSize
...
...
@@ -381,7 +383,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
for
!
unknown
&&
len
(
headers
)
<
int
(
query
.
Amount
)
&&
bytes
<
softResponseLimit
&&
len
(
headers
)
<
downloader
.
MaxHeaderFetch
{
// Retrieve the next header satisfying the query
var
origin
*
types
.
Header
if
query
.
Origin
.
Hash
!=
(
common
.
Hash
{})
{
if
hashMode
{
origin
=
pm
.
blockchain
.
GetHeader
(
query
.
Origin
.
Hash
)
}
else
{
origin
=
pm
.
blockchain
.
GetHeaderByNumber
(
query
.
Origin
.
Number
)
...
...
eth/handler_test.go
View file @
e51eeb81
...
...
@@ -301,6 +301,15 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
pm
.
blockchain
.
GetBlockByNumber
(
1
)
.
Hash
(),
},
},
// Check a corner case where requesting more can iterate past the endpoints
{
&
getBlockHeadersData
{
Origin
:
hashOrNumber
{
Number
:
2
},
Amount
:
5
,
Reverse
:
true
},
[]
common
.
Hash
{
pm
.
blockchain
.
GetBlockByNumber
(
2
)
.
Hash
(),
pm
.
blockchain
.
GetBlockByNumber
(
1
)
.
Hash
(),
pm
.
blockchain
.
GetBlockByNumber
(
0
)
.
Hash
(),
},
},
// Check that non existing headers aren't returned
{
&
getBlockHeadersData
{
Origin
:
hashOrNumber
{
Hash
:
unknown
},
Amount
:
1
},
...
...
@@ -322,6 +331,17 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
if
err
:=
p2p
.
ExpectMsg
(
peer
.
app
,
0x04
,
headers
);
err
!=
nil
{
t
.
Errorf
(
"test %d: headers mismatch: %v"
,
i
,
err
)
}
// If the test used number origins, repeat with hashes as the too
if
tt
.
query
.
Origin
.
Hash
==
(
common
.
Hash
{})
{
if
origin
:=
pm
.
blockchain
.
GetBlockByNumber
(
tt
.
query
.
Origin
.
Number
);
origin
!=
nil
{
tt
.
query
.
Origin
.
Hash
,
tt
.
query
.
Origin
.
Number
=
origin
.
Hash
(),
0
p2p
.
Send
(
peer
.
app
,
0x03
,
tt
.
query
)
if
err
:=
p2p
.
ExpectMsg
(
peer
.
app
,
0x04
,
headers
);
err
!=
nil
{
t
.
Errorf
(
"test %d: headers mismatch: %v"
,
i
,
err
)
}
}
}
}
}
...
...
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