feat: Add Vasil / Babbage compatibility (#126)
* feat: Bump n2n protocol versions for Babbage (#125) * feat: Allow a specified timeout on tcp connection (#127) * feat: Add Babbage primitives (#128) * fix: Inaccurate header-body CDDL (#129) * fix: Babbage CBOR codec issues (#130) * feat: Include Babbage in traverse lib * Parse Babbage headers (#131) * Add Babbage nonce/leader vrf extension (#132) Co-authored-by: Andrew Westberg <andrewwestberg@gmail.com>
This commit is contained in:
parent
dd42b951a3
commit
4e08620bc4
22 changed files with 1826 additions and 90 deletions
|
|
@ -1,13 +1,14 @@
|
|||
use byteorder::{ByteOrder, NetworkEndian, WriteBytesExt};
|
||||
use log::{debug, log_enabled, trace};
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{TcpListener, ToSocketAddrs};
|
||||
use std::net::{SocketAddr, TcpListener, ToSocketAddrs};
|
||||
use std::{net::TcpStream, time::Instant};
|
||||
|
||||
use crate::Payload;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct Segment {
|
||||
pub protocol: u16,
|
||||
|
|
@ -110,6 +111,16 @@ impl Bearer {
|
|||
Ok(Bearer::Tcp(bearer))
|
||||
}
|
||||
|
||||
pub fn connect_tcp_timeout(
|
||||
addr: &SocketAddr,
|
||||
timeout: Duration,
|
||||
) -> Result<Self, std::io::Error> {
|
||||
let bearer = TcpStream::connect_timeout(addr, timeout)?;
|
||||
bearer.set_nodelay(true)?;
|
||||
|
||||
Ok(Bearer::Tcp(bearer))
|
||||
}
|
||||
|
||||
pub fn accept_tcp(server: TcpListener) -> Result<Self, std::io::Error> {
|
||||
let (bearer, _) = server.accept().unwrap();
|
||||
bearer.set_nodelay(true)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue