Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
f04486e5
Commit
f04486e5
authored
5 years ago
by
Pierre Krieger
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Increase limit on light client response size (#5461)
* Increase limit on light client response size * Address review
parent
9789054f
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/network/src/protocol/light_client_handler.rs
+22
-13
22 additions, 13 deletions
...trate/client/network/src/protocol/light_client_handler.rs
with
22 additions
and
13 deletions
substrate/client/network/src/protocol/light_client_handler.rs
+
22
−
13
View file @
f04486e5
...
...
@@ -77,7 +77,8 @@ use wasm_timer::Instant;
/// Configuration options for `LightClientHandler` behaviour.
#[derive(Debug,
Clone)]
pub
struct
Config
{
max_data_size
:
usize
,
max_request_size
:
usize
,
max_response_size
:
usize
,
max_pending_requests
:
usize
,
inactivity_timeout
:
Duration
,
request_timeout
:
Duration
,
...
...
@@ -87,13 +88,15 @@ pub struct Config {
impl
Config
{
/// Create a fresh configuration with the following options:
///
/// - max. data size = 1 MiB
/// - max. request size = 1 MiB
/// - max. response size = 16 MiB
/// - max. pending requests = 128
/// - inactivity timeout = 15s
/// - request timeout = 15s
pub
fn
new
(
id
:
&
ProtocolId
)
->
Self
{
let
mut
c
=
Config
{
max_data_size
:
1024
*
1024
,
max_request_size
:
1
*
1024
*
1024
,
max_response_size
:
16
*
1024
*
1024
,
max_pending_requests
:
128
,
inactivity_timeout
:
Duration
::
from_secs
(
15
),
request_timeout
:
Duration
::
from_secs
(
15
),
...
...
@@ -103,9 +106,15 @@ impl Config {
c
}
/// Limit the max. length of incoming request bytes.
pub
fn
set_max_data_size
(
&
mut
self
,
v
:
usize
)
->
&
mut
Self
{
self
.max_data_size
=
v
;
/// Limit the max. length in bytes of a request.
pub
fn
set_max_request_size
(
&
mut
self
,
v
:
usize
)
->
&
mut
Self
{
self
.max_request_size
=
v
;
self
}
/// Limit the max. length in bytes of a response.
pub
fn
set_max_response_size
(
&
mut
self
,
v
:
usize
)
->
&
mut
Self
{
self
.max_response_size
=
v
;
self
}
...
...
@@ -654,7 +663,7 @@ where
fn
new_handler
(
&
mut
self
)
->
Self
::
ProtocolsHandler
{
let
p
=
InboundProtocol
{
max_
data
_size
:
self
.config.max_
data
_size
,
max_
request
_size
:
self
.config.max_
request
_size
,
protocol
:
self
.config.protocol
.clone
(),
};
OneShotHandler
::
new
(
SubstreamProtocol
::
new
(
p
),
self
.config.inactivity_timeout
)
...
...
@@ -841,7 +850,7 @@ where
let
protocol
=
OutboundProtocol
{
request
:
buf
,
request_id
:
id
,
max_
data
_size
:
self
.config.max_
data
_size
,
max_
response
_size
:
self
.config.max_
response
_size
,
protocol
:
self
.config.protocol
.clone
(),
};
self
.peers
.get_mut
(
&
peer
)
.map
(|
info
|
info
.status
=
PeerStatus
::
BusyWith
(
id
));
...
...
@@ -1008,7 +1017,7 @@ pub enum Event<T> {
#[derive(Debug,
Clone)]
pub
struct
InboundProtocol
{
/// The max. request length in bytes.
max_
data
_size
:
usize
,
max_
request
_size
:
usize
,
/// The protocol to use for upgrade negotiation.
protocol
:
Bytes
,
}
...
...
@@ -1032,7 +1041,7 @@ where
fn
upgrade_inbound
(
self
,
mut
s
:
T
,
_
:
Self
::
Info
)
->
Self
::
Future
{
let
future
=
async
move
{
let
vec
=
read_one
(
&
mut
s
,
self
.max_
data
_size
)
.await
?
;
let
vec
=
read_one
(
&
mut
s
,
self
.max_
request
_size
)
.await
?
;
match
api
::
v1
::
light
::
Request
::
decode
(
&
vec
[
..
])
{
Ok
(
r
)
=>
Ok
(
Event
::
Request
(
r
,
s
)),
Err
(
e
)
=>
Err
(
ReadOneError
::
Io
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
e
)))
...
...
@@ -1051,8 +1060,8 @@ pub struct OutboundProtocol {
request
:
Vec
<
u8
>
,
/// Local identifier for the request. Used to associate it with a response.
request_id
:
u64
,
/// The max. re
quest
length in bytes.
max_
data
_size
:
usize
,
/// The max. re
sponse
length in bytes.
max_
response
_size
:
usize
,
/// The protocol to use for upgrade negotiation.
protocol
:
Bytes
,
}
...
...
@@ -1077,7 +1086,7 @@ where
fn
upgrade_outbound
(
self
,
mut
s
:
T
,
_
:
Self
::
Info
)
->
Self
::
Future
{
let
future
=
async
move
{
write_one
(
&
mut
s
,
&
self
.request
)
.await
?
;
let
vec
=
read_one
(
&
mut
s
,
self
.max_
data
_size
)
.await
?
;
let
vec
=
read_one
(
&
mut
s
,
self
.max_
response
_size
)
.await
?
;
api
::
v1
::
light
::
Response
::
decode
(
&
vec
[
..
])
.map
(|
r
|
Event
::
Response
(
self
.request_id
,
r
))
.map_err
(|
e
|
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment