Skip to content

fix bindings/wasm wal file creation by implementing generate_random_number #1556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions bindings/wasm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,16 @@ impl limbo_core::IO for PlatformIO {
}

fn generate_random_number(&self) -> i64 {
let random_f64 = Math_random();
(random_f64 * i64::MAX as f64) as i64
let mut buf = [0u8; 8];
getrandom::getrandom(&mut buf).unwrap();
i64::from_ne_bytes(buf)
}

fn get_memory_io(&self) -> Arc<limbo_core::MemoryIO> {
Arc::new(limbo_core::MemoryIO::new())
}
}

#[wasm_bindgen]
extern "C" {
fn Math_random() -> f64;
}

#[wasm_bindgen]
extern "C" {
type Date;
Expand Down
Loading