Skip to content

Commit 58b5f26

Browse files
committed
Cleanup
1 parent 61ffd83 commit 58b5f26

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

crates/core/src/host/instance_env.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use spacetimedb_sats::{
1616
};
1717
use spacetimedb_table::indexes::RowPointer;
1818
use spacetimedb_table::table::RowRef;
19+
use std::fmt::Display;
1920
use std::ops::DerefMut;
2021
use std::sync::Arc;
2122

@@ -499,6 +500,13 @@ impl From<GetTxError> for NodesError {
499500
}
500501
}
501502

503+
impl Display for GetTxError {
504+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
505+
write!(f, "not in a transaction")
506+
}
507+
}
508+
impl std::error::Error for GetTxError {}
509+
502510
#[cfg(test)]
503511
mod test {
504512
use super::*;

crates/core/src/host/wasmtime/wasm_instance_env.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,15 +1214,13 @@ impl WasmInstanceEnv {
12141214
connection_id: WasmPtr<ConnectionId>,
12151215
out_ptr: WasmPtr<u32>,
12161216
) -> RtResult<()> {
1217-
log::info!("Calling has_jwt");
12181217
Self::with_span(caller, AbiCall::JwtLength, |caller| {
12191218
let (mem, env) = Self::mem_env(caller);
12201219
let cid = ConnectionId::read_from(mem, connection_id)?;
12211220
let length = env
12221221
.instance_env
12231222
.tx
1224-
.get()
1225-
.unwrap()
1223+
.get()?
12261224
.get_jwt_payload(cid)?
12271225
.map(|p| p.len() as u32)
12281226
.unwrap_or(0u32);
@@ -1241,33 +1239,27 @@ impl WasmInstanceEnv {
12411239
Self::with_span(caller, AbiCall::GetJwt, |caller| {
12421240
let (mem, env) = Self::mem_env(caller);
12431241
let cid = ConnectionId::read_from(mem, connection_id)?;
1244-
let jwt = match env.instance_env.tx.get().unwrap().get_jwt_payload(cid)? {
1242+
let jwt = match env.instance_env.tx.get()?.get_jwt_payload(cid)? {
12451243
None => {
12461244
// Consider logging here, since this should only happen during an upgrade.
12471245
0u32.write_to(mem, target_ptr_len)?;
12481246
return Ok(());
12491247
}
12501248
Some(jwt) => jwt,
12511249
};
1252-
log::info!("JWT payload found for connection ID: {:?}: {}", cid.to_hex(), jwt);
12531250
let jwt_len = jwt.len();
12541251
// Read `buffer_len`, i.e., the capacity of `buffer` pointed to by `buffer_ptr`.
12551252
let buffer_len = u32::read_from(mem, target_ptr_len)?;
1256-
log::info!("buffer_len: {buffer_len}");
12571253
if buffer_len < jwt_len as u32 {
12581254
return Err(anyhow::anyhow!("buffer too small to hold JWT payload"));
12591255
}
1260-
log::info!("About to write length");
12611256
// Write the length of the JWT payload to the target pointer.
12621257
(jwt_len as u32).write_to(mem, target_ptr_len)?;
1263-
log::info!("wrote length of {jwt_len}");
1264-
log::info!("Byte len {}", jwt.len());
12651258

12661259
// Write the JWT payload to the target pointer.
12671260
// Get a mutable view to the `buffer`.
12681261
let buffer = mem.deref_slice_mut(target_ptr, buffer_len)?;
12691262
buffer[..jwt_len].copy_from_slice(jwt.as_bytes());
1270-
log::info!("wrote jwt bytes to slice");
12711263
Ok(())
12721264
})
12731265
}

0 commit comments

Comments
 (0)