Skip to content

Commit

Permalink
expose context id to the storage env (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
chefsale authored Oct 31, 2024
1 parent 399d6bb commit e9ae279
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/storage/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ pub fn time_now() -> u64 {
imp::time_now()
}

/// Return the context id.
#[must_use]
pub fn context_id() -> [u8; 32] {
imp::context_id()
}

#[cfg(target_arch = "wasm32")]
mod calimero_vm {
use calimero_sdk::env;
Expand Down Expand Up @@ -118,6 +124,11 @@ mod calimero_vm {
env::random_bytes(buf)
}

/// Return the context id.
pub(super) fn context_id() -> [u8; 32] {
env::context_id()
}

/// Gets the current time.
///
/// This function obtains the current time as a nanosecond timestamp.
Expand Down Expand Up @@ -169,6 +180,11 @@ mod mocked {
rand::thread_rng().fill_bytes(buf);
}

/// Return the context id.
pub(super) fn context_id() -> [u8; 32] {
[0; 32]
}

/// Gets the current time.
///
/// This function obtains the current time as a nanosecond timestamp.
Expand Down

0 comments on commit e9ae279

Please sign in to comment.