forked from txpipe/pallas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsender.rs
33 lines (25 loc) · 928 Bytes
/
sender.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::{net::TcpStream, thread, time::Duration};
use log::info;
use pallas_multiplexer::{Channel, Multiplexer};
const PROTOCOLS: [u16; 2] = [0x0002u16, 0x0003u16];
fn main() {
env_logger::init();
info!("connecting to tcp socket on 127.0.0.1:3001");
let bearer = TcpStream::connect("127.0.0.1:3001").unwrap();
let mut muxer = Multiplexer::setup(bearer, &PROTOCOLS).unwrap();
for protocol in PROTOCOLS {
let handle = muxer.use_channel(protocol);
thread::spawn(move || {
let Channel(tx, _) = handle;
loop {
let payload = vec![1; 65545];
info!("sending dumb payload for protocol: {}", protocol);
tx.send(payload).unwrap();
thread::sleep(Duration::from_millis(500u64 + (protocol as u64 * 10u64)));
}
});
}
loop {
thread::sleep(Duration::from_secs(6000));
}
}