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
aeb73362
Commit
aeb73362
authored
Oct 19, 2018
by
Elad
Committed by
Viktor Trón
Oct 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/network: disallow historical retrieval requests (#17936)
parent
97fb0834
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
7 deletions
+11
-7
delivery_test.go
swarm/network/stream/delivery_test.go
+1
-1
messages.go
swarm/network/stream/messages.go
+1
-0
snapshot_retrieval_test.go
swarm/network/stream/snapshot_retrieval_test.go
+2
-2
snapshot_sync_test.go
swarm/network/stream/snapshot_sync_test.go
+2
-2
stream.go
swarm/network/stream/stream.go
+5
-2
No files found.
swarm/network/stream/delivery_test.go
View file @
aeb73362
...
@@ -416,7 +416,7 @@ func testDeliveryFromNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
...
@@ -416,7 +416,7 @@ func testDeliveryFromNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
return
fmt
.
Errorf
(
"No registry"
)
return
fmt
.
Errorf
(
"No registry"
)
}
}
registry
:=
item
.
(
*
Registry
)
registry
:=
item
.
(
*
Registry
)
err
=
registry
.
Subscribe
(
sid
,
NewStream
(
swarmChunkServerStreamName
,
""
,
true
),
NewRange
(
0
,
0
)
,
Top
)
err
=
registry
.
Subscribe
(
sid
,
NewStream
(
swarmChunkServerStreamName
,
""
,
true
),
nil
,
Top
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
swarm/network/stream/messages.go
View file @
aeb73362
...
@@ -158,6 +158,7 @@ type SubscribeErrorMsg struct {
...
@@ -158,6 +158,7 @@ type SubscribeErrorMsg struct {
}
}
func
(
p
*
Peer
)
handleSubscribeErrorMsg
(
req
*
SubscribeErrorMsg
)
(
err
error
)
{
func
(
p
*
Peer
)
handleSubscribeErrorMsg
(
req
*
SubscribeErrorMsg
)
(
err
error
)
{
//TODO the error should be channeled to whoever calls the subscribe
return
fmt
.
Errorf
(
"subscribe to peer %s: %v"
,
p
.
ID
(),
req
.
Error
)
return
fmt
.
Errorf
(
"subscribe to peer %s: %v"
,
p
.
ID
(),
req
.
Error
)
}
}
...
...
swarm/network/stream/snapshot_retrieval_test.go
View file @
aeb73362
...
@@ -218,7 +218,7 @@ func runFileRetrievalTest(nodeCount int) error {
...
@@ -218,7 +218,7 @@ func runFileRetrievalTest(nodeCount int) error {
reader
,
_
:=
fileStore
.
Retrieve
(
context
.
TODO
(),
hash
)
reader
,
_
:=
fileStore
.
Retrieve
(
context
.
TODO
(),
hash
)
//check that we can read the file size and that it corresponds to the generated file size
//check that we can read the file size and that it corresponds to the generated file size
if
s
,
err
:=
reader
.
Size
(
ctx
,
nil
);
err
!=
nil
||
s
!=
int64
(
len
(
randomFiles
[
i
]))
{
if
s
,
err
:=
reader
.
Size
(
ctx
,
nil
);
err
!=
nil
||
s
!=
int64
(
len
(
randomFiles
[
i
]))
{
log
.
Warn
(
"Retrieve error"
,
"err"
,
err
,
"hash"
,
hash
,
"nodeId"
,
id
)
log
.
Debug
(
"Retrieve error"
,
"err"
,
err
,
"hash"
,
hash
,
"nodeId"
,
id
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
REPEAT
continue
REPEAT
}
}
...
@@ -309,7 +309,7 @@ func runRetrievalTest(chunkCount int, nodeCount int) error {
...
@@ -309,7 +309,7 @@ func runRetrievalTest(chunkCount int, nodeCount int) error {
reader
,
_
:=
fileStore
.
Retrieve
(
context
.
TODO
(),
hash
)
reader
,
_
:=
fileStore
.
Retrieve
(
context
.
TODO
(),
hash
)
//check that we can read the chunk size and that it corresponds to the generated chunk size
//check that we can read the chunk size and that it corresponds to the generated chunk size
if
s
,
err
:=
reader
.
Size
(
ctx
,
nil
);
err
!=
nil
||
s
!=
int64
(
chunkSize
)
{
if
s
,
err
:=
reader
.
Size
(
ctx
,
nil
);
err
!=
nil
||
s
!=
int64
(
chunkSize
)
{
log
.
Warn
(
"Retrieve error"
,
"err"
,
err
,
"hash"
,
hash
,
"nodeId"
,
id
,
"size"
,
s
)
log
.
Debug
(
"Retrieve error"
,
"err"
,
err
,
"hash"
,
hash
,
"nodeId"
,
id
,
"size"
,
s
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
REPEAT
continue
REPEAT
}
}
...
...
swarm/network/stream/snapshot_sync_test.go
View file @
aeb73362
...
@@ -310,7 +310,7 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
...
@@ -310,7 +310,7 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
_
,
err
=
lstore
.
Get
(
ctx
,
chunk
)
_
,
err
=
lstore
.
Get
(
ctx
,
chunk
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warn
(
fmt
.
Sprintf
(
"Chunk %s NOT found for id %s"
,
chunk
,
id
))
log
.
Debug
(
fmt
.
Sprintf
(
"Chunk %s NOT found for id %s"
,
chunk
,
id
))
// Do not get crazy with logging the warn message
// Do not get crazy with logging the warn message
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
REPEAT
continue
REPEAT
...
@@ -514,7 +514,7 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
...
@@ -514,7 +514,7 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
_
,
err
=
lstore
.
Get
(
ctx
,
chunk
)
_
,
err
=
lstore
.
Get
(
ctx
,
chunk
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warn
(
fmt
.
Sprintf
(
"Chunk %s NOT found for id %s"
,
chunk
,
id
))
log
.
Debug
(
fmt
.
Sprintf
(
"Chunk %s NOT found for id %s"
,
chunk
,
id
))
// Do not get crazy with logging the warn message
// Do not get crazy with logging the warn message
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
REPEAT
continue
REPEAT
...
...
swarm/network/stream/stream.go
View file @
aeb73362
...
@@ -18,6 +18,7 @@ package stream
...
@@ -18,6 +18,7 @@ package stream
import
(
import
(
"context"
"context"
"errors"
"fmt"
"fmt"
"math"
"math"
"sync"
"sync"
...
@@ -96,7 +97,10 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
...
@@ -96,7 +97,10 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
delivery
.
getPeer
=
streamer
.
getPeer
delivery
.
getPeer
=
streamer
.
getPeer
if
options
.
DoServeRetrieve
{
if
options
.
DoServeRetrieve
{
streamer
.
RegisterServerFunc
(
swarmChunkServerStreamName
,
func
(
_
*
Peer
,
_
string
,
_
bool
)
(
Server
,
error
)
{
streamer
.
RegisterServerFunc
(
swarmChunkServerStreamName
,
func
(
_
*
Peer
,
_
string
,
live
bool
)
(
Server
,
error
)
{
if
!
live
{
return
nil
,
errors
.
New
(
"only live retrieval requests supported"
)
}
return
NewSwarmChunkServer
(
delivery
.
chunkStore
),
nil
return
NewSwarmChunkServer
(
delivery
.
chunkStore
),
nil
})
})
}
}
...
@@ -279,7 +283,6 @@ func (r *Registry) Subscribe(peerId enode.ID, s Stream, h *Range, priority uint8
...
@@ -279,7 +283,6 @@ func (r *Registry) Subscribe(peerId enode.ID, s Stream, h *Range, priority uint8
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
s
.
Live
&&
h
!=
nil
{
if
s
.
Live
&&
h
!=
nil
{
if
err
:=
peer
.
setClientParams
(
if
err
:=
peer
.
setClientParams
(
getHistoryStream
(
s
),
getHistoryStream
(
s
),
...
...
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