@@ -46,6 +46,11 @@ use syslog::Facility;
46
46
use cli_config:: * ;
47
47
use motd:: { Motd , Counters } ;
48
48
49
+ /// Channel size for onion messages between UDP and TCP relay.
50
+ const ONION_CHANNEL_SIZE : usize = 32 ;
51
+ /// Channel size for DHT packets.
52
+ const DHT_CHANNEL_SIZE : usize = 32 ;
53
+
49
54
/// Get version in format 3AAABBBCCC, where A B and C are major, minor and patch
50
55
/// versions of node. `tox-bootstrapd` uses similar scheme but with leading 1.
51
56
/// Before it used format YYYYMMDDVV so the leading numeral was 2. To make a
@@ -136,23 +141,23 @@ fn run<F>(future: F, threads_config: ThreadsConfig)
136
141
/// Onion sink and stream for TCP.
137
142
struct TcpOnion {
138
143
/// Sink for onion packets from TCP to UDP.
139
- tx : mpsc:: UnboundedSender < ( OnionRequest , SocketAddr ) > ,
144
+ tx : mpsc:: Sender < ( OnionRequest , SocketAddr ) > ,
140
145
/// Stream of onion packets from TCP to UDP.
141
- rx : mpsc:: UnboundedReceiver < ( InnerOnionResponse , SocketAddr ) > ,
146
+ rx : mpsc:: Receiver < ( InnerOnionResponse , SocketAddr ) > ,
142
147
}
143
148
144
149
/// Onion sink and stream for UDP.
145
150
struct UdpOnion {
146
151
/// Sink for onion packets from UDP to TCP.
147
- tx : mpsc:: UnboundedSender < ( InnerOnionResponse , SocketAddr ) > ,
152
+ tx : mpsc:: Sender < ( InnerOnionResponse , SocketAddr ) > ,
148
153
/// Stream of onion packets from TCP to UDP.
149
- rx : mpsc:: UnboundedReceiver < ( OnionRequest , SocketAddr ) > ,
154
+ rx : mpsc:: Receiver < ( OnionRequest , SocketAddr ) > ,
150
155
}
151
156
152
157
/// Create onion streams for TCP and UDP servers communication.
153
158
fn create_onion_streams ( ) -> ( TcpOnion , UdpOnion ) {
154
- let ( udp_onion_tx, udp_onion_rx) = mpsc:: unbounded ( ) ;
155
- let ( tcp_onion_tx, tcp_onion_rx) = mpsc:: unbounded ( ) ;
159
+ let ( udp_onion_tx, udp_onion_rx) = mpsc:: channel ( ONION_CHANNEL_SIZE ) ;
160
+ let ( tcp_onion_tx, tcp_onion_rx) = mpsc:: channel ( ONION_CHANNEL_SIZE ) ;
156
161
let tcp_onion = TcpOnion {
157
162
tx : tcp_onion_tx,
158
163
rx : udp_onion_rx,
@@ -224,7 +229,7 @@ fn run_udp(cli_config: &CliConfig, dht_pk: PublicKey, dht_sk: &SecretKey, udp_on
224
229
let ( sink, stream) = UdpFramed :: new ( socket, codec) . split ( ) ;
225
230
226
231
// Create a channel for server to communicate with network
227
- let ( tx, rx) = mpsc:: unbounded ( ) ;
232
+ let ( tx, rx) = mpsc:: channel ( DHT_CHANNEL_SIZE ) ;
228
233
229
234
let lan_discovery_future = if cli_config. lan_discovery_enabled {
230
235
Either :: A ( LanDiscoverySender :: new ( tx. clone ( ) , dht_pk, udp_addr. is_ipv6 ( ) )
0 commit comments