removing dev branch, many changes

This commit is contained in:
John Smith
2023-05-29 19:24:57 +00:00
parent 1430f3f656
commit 0a890c8707
250 changed files with 18084 additions and 8040 deletions

View File

@@ -11,8 +11,9 @@ crate-type = [ "cdylib", "staticlib", "rlib" ]
[features]
default = []
rt-async-std = [ "async-std", "async_executors/async_std", ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", ]
rt-async-std = [ "async-std", "async_executors/async_std" ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer" ]
rt-wasm-bindgen = [ "async_executors/bindgen", "async_executors/timer"]
veilid_tools_android_tests = [ "dep:paranoid-android" ]
veilid_tools_ios_tests = [ "dep:oslog", "dep:tracing-oslog" ]
@@ -52,7 +53,7 @@ nix = "^0"
wasm-bindgen = "^0"
js-sys = "^0"
wasm-bindgen-futures = "^0"
async_executors = { version = "^0", default-features = false, features = [ "bindgen", "timer" ]}
async_executors = { version = "^0", default-features = false}
async-lock = "^2"
send_wrapper = { version = "^0.6", features = ["futures"] }

View File

@@ -3,7 +3,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd $SCRIPTDIR 2>/dev/null
if [[ "$1" == "wasm" ]]; then
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless --features=rt-wasm-bindgen
elif [[ "$1" == "ios" ]]; then
SYMROOT=/tmp/testout
APPNAME=veilidtools-tests

View File

@@ -1,6 +1,6 @@
// LogThru
// Pass errors through and log them simultaneously via map_err()
// Also contains common log facilities (net, rpc, rtab, pstore, crypto, etc )
// Also contains common log facilities (net, rpc, rtab, stor, pstore, crypto, etc )
use super::*;
@@ -123,6 +123,42 @@ macro_rules! log_rtab {
}
}
#[macro_export]
macro_rules! log_stor {
(error $text:expr) => { error!(
target: "stor",
"{}",
$text,
)};
(error $fmt:literal, $($arg:expr),+) => {
error!(target:"stor", $fmt, $($arg),+);
};
(warn $text:expr) => { warn!(
target: "stor",
"{}",
$text,
)};
(warn $fmt:literal, $($arg:expr),+) => {
warn!(target:"stor", $fmt, $($arg),+);
};
(debug $text:expr) => { debug!(
target: "stor",
"{}",
$text,
)};
(debug $fmt:literal, $($arg:expr),+) => {
debug!(target:"stor", $fmt, $($arg),+);
};
($text:expr) => {trace!(
target: "stor",
"{}",
$text,
)};
($fmt:literal, $($arg:expr),+) => {
trace!(target:"stor", $fmt, $($arg),+);
}
}
#[macro_export]
macro_rules! log_pstore {
(error $text:expr) => { error!(
@@ -216,6 +252,18 @@ macro_rules! logthru_rtab {
}
}
#[macro_export]
macro_rules! logthru_stor {
($($level:ident)?) => {
logthru!($($level)? "stor")
};
($($level:ident)? $text:literal) => {
logthru!($($level)? "stor", $text)
};
($($level:ident)? $fmt:literal, $($arg:expr),+) => {
logthru!($($level)? "stor", $fmt, $($arg),+)
}
}
#[macro_export]
macro_rules! logthru_pstore {
($($level:ident)?) => {
logthru!($($level)? "pstore")

View File

@@ -16,13 +16,12 @@ impl RngCore for VeilidRng {
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
if let Err(e) = self.try_fill_bytes(dest) {
panic!("Error: {}", e);
}
random_bytes(dest);
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
random_bytes(dest).map_err(rand::Error::new)
random_bytes(dest);
Ok(())
}
}
@@ -30,7 +29,7 @@ cfg_if! {
if #[cfg(target_arch = "wasm32")] {
use js_sys::Math;
pub fn random_bytes(dest: &mut [u8]) -> EyreResult<()> {
pub fn random_bytes(dest: &mut [u8]) {
let len = dest.len();
let u32len = len / 4;
let remlen = len % 4;
@@ -49,8 +48,6 @@ cfg_if! {
dest[u32len * 4 + n] = ((r >> (n * 8)) & 0xFF) as u8;
}
}
Ok(())
}
pub fn get_random_u32() -> u32 {
@@ -65,9 +62,9 @@ cfg_if! {
} else {
pub fn random_bytes(dest: &mut [u8]) -> EyreResult<()> {
pub fn random_bytes(dest: &mut [u8]) {
let mut rng = rand::thread_rng();
rng.try_fill_bytes(dest).wrap_err("failed to fill bytes")
rng.fill_bytes(dest);
}
pub fn get_random_u32() -> u32 {

View File

@@ -32,6 +32,37 @@ macro_rules! bail_io_error_other {
};
}
cfg_if::cfg_if! {
if #[cfg(feature="rt-tokio")] {
#[macro_export]
macro_rules! asyncmutex_try_lock {
($x:expr) => {
$x.try_lock().ok()
};
}
#[macro_export]
macro_rules! asyncmutex_lock_arc {
($x:expr) => {
$x.clone().lock_owned().await
};
}
} else {
#[macro_export]
macro_rules! asyncmutex_try_lock {
($x:expr) => {
$x.try_lock()
};
}
#[macro_export]
macro_rules! asyncmutex_lock_arc {
($x:expr) => {
$x.lock_arc().await
};
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
pub fn system_boxed<'a, Out>(
@@ -99,6 +130,10 @@ pub fn ms_to_us(ms: u32) -> u64 {
(ms as u64) * 1000u64
}
pub fn us_to_ms(us: u64) -> EyreResult<u32> {
u32::try_from(us / 1000u64).wrap_err("could not convert microseconds")
}
// Calculate retry attempt with logarhythmic falloff
pub fn retry_falloff_log(
last_us: u64,