@@ -32,6 +32,8 @@ pub struct ClientConfiguration {
3232 #[ wasm_bindgen( skip) ]
3333 pub peer_count_per_subnet_max : usize ,
3434 #[ wasm_bindgen( skip) ]
35+ pub network_buffer_size : usize ,
36+ #[ wasm_bindgen( skip) ]
3537 pub sync_mode : String ,
3638 #[ wasm_bindgen( skip) ]
3739 pub num_initial_connections : usize ,
@@ -63,6 +65,8 @@ pub struct PlainClientConfiguration {
6365 #[ cfg_attr( feature = "client" , serde( skip_serializing_if = "Option::is_none" ) ) ]
6466 pub peer_count_per_subnet_max : Option < usize > ,
6567 #[ cfg_attr( feature = "client" , serde( skip_serializing_if = "Option::is_none" ) ) ]
68+ pub network_buffer_size : Option < usize > ,
69+ #[ cfg_attr( feature = "client" , serde( skip_serializing_if = "Option::is_none" ) ) ]
6670 pub sync_mode : Option < String > ,
6771 #[ cfg_attr( feature = "client" , serde( skip_serializing_if = "Option::is_none" ) ) ]
6872 pub num_initial_connections : Option < usize > ,
@@ -96,6 +100,7 @@ impl Default for ClientConfiguration {
96100 peer_count_per_subnet_max : 10 ,
97101 sync_mode : "light" . to_string ( ) ,
98102 num_initial_connections : 4 ,
103+ network_buffer_size : 1024 ,
99104 }
100105 }
101106}
@@ -176,6 +181,16 @@ impl ClientConfiguration {
176181 self . peer_count_per_subnet_max = peer_count_per_subnet_max;
177182 }
178183
184+ /// Sets the maximum network buffer size, which should be greater than 0
185+ /// Default is `1024`.
186+ #[ wasm_bindgen( js_name = networkBufferSize) ]
187+ pub fn network_buffer_size ( & mut self , network_buffer_size : usize ) {
188+ if network_buffer_size == 0_usize {
189+ panic ! ( "The network buffer size needs to be greater than 0" )
190+ }
191+ self . network_buffer_size = network_buffer_size;
192+ }
193+
179194 /// Sets the sync mode that shoud be used.
180195 /// Only "light" and "pico" are supported for web clients
181196 /// Default is "light"
@@ -207,6 +222,7 @@ impl ClientConfiguration {
207222 peer_count_per_subnet_max : Some ( self . peer_count_per_subnet_max ) ,
208223 sync_mode : Some ( self . sync_mode . clone ( ) ) ,
209224 num_initial_connections : Some ( self . num_initial_connections ) ,
225+ network_buffer_size : Some ( self . network_buffer_size ) ,
210226 } )
211227 . unwrap ( )
212228 . into ( )
@@ -253,6 +269,10 @@ impl TryFrom<PlainClientConfiguration> for ClientConfiguration {
253269 client_config. peer_count_per_subnet_max = peer_count_per_subnet_max;
254270 }
255271
272+ if let Some ( network_buffer_size) = config. network_buffer_size {
273+ client_config. network_buffer_size = network_buffer_size;
274+ }
275+
256276 if let Some ( sync_mode) = config. sync_mode {
257277 // Only "pico" and "light" sync modes are supported for web clients
258278 if !( sync_mode == "pico" || sync_mode == "light" ) {
0 commit comments