Skip to content

Commit ef30e09

Browse files
committed
with_transaction -> with_tx
1 parent 32420d8 commit ef30e09

File tree

6 files changed

+34
-40
lines changed

6 files changed

+34
-40
lines changed

crates/bindings-sys/src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ pub mod raw {
682682
/// Returns an error:
683683
///
684684
/// - `WOULD_BLOCK_TRANSACTION`, if there's already an ongoing transaction.
685-
pub fn procedure_start_mut_transaction(out: *mut i64) -> u16;
685+
pub fn procedure_start_mut_tx(out: *mut i64) -> u16;
686686

687687
/// Commits a mutable transaction,
688688
/// suspending execution of this WASM instance until
@@ -700,14 +700,14 @@ pub mod raw {
700700
/// Returns an error:
701701
///
702702
/// - `TRANSACTION_NOT_ANONYMOUS`,
703-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
703+
/// if the transaction was not started in [`procedure_start_mut_tx`].
704704
/// This can happen if this syscall is erroneously called by a reducer.
705705
/// The code `NOT_IN_TRANSACTION` does not happen,
706706
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
707707
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
708708
/// This currently does not happen as anonymous read transactions
709709
/// are not exposed to modules.
710-
pub fn procedure_commit_mut_transaction() -> u16;
710+
pub fn procedure_commit_mut_tx() -> u16;
711711

712712
/// Aborts a mutable transaction,
713713
/// suspending execution of this WASM instance until
@@ -724,14 +724,14 @@ pub mod raw {
724724
/// Returns an error:
725725
///
726726
/// - `TRANSACTION_NOT_ANONYMOUS`,
727-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
727+
/// if the transaction was not started in [`procedure_start_mut_tx`].
728728
/// This can happen if this syscall is erroneously called by a reducer.
729729
/// The code `NOT_IN_TRANSACTION` does not happen,
730730
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
731731
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
732732
/// This currently does not happen as anonymous read transactions
733733
/// are not exposed to modules.
734-
pub fn procedure_abort_mut_transaction() -> u16;
734+
pub fn procedure_abort_mut_tx() -> u16;
735735
}
736736

737737
/// What strategy does the database index use?
@@ -1346,8 +1346,8 @@ pub mod procedure {
13461346
///
13471347
/// - `WOULD_BLOCK_TRANSACTION`, if there's already an ongoing transaction.
13481348
#[inline]
1349-
pub fn procedure_start_mut_transaction() -> Result<i64> {
1350-
unsafe { call(|out| raw::procedure_start_mut_transaction(out)) }
1349+
pub fn procedure_start_mut_tx() -> Result<i64> {
1350+
unsafe { call(|out| raw::procedure_start_mut_tx(out)) }
13511351
}
13521352

13531353
/// Commits a mutable transaction,
@@ -1362,16 +1362,16 @@ pub mod procedure {
13621362
/// Returns an error:
13631363
///
13641364
/// - `TRANSACTION_NOT_ANONYMOUS`,
1365-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
1365+
/// if the transaction was not started in [`procedure_start_mut_tx`].
13661366
/// This can happen if this syscall is erroneously called by a reducer.
13671367
/// The code `NOT_IN_TRANSACTION` does not happen,
13681368
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
13691369
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
13701370
/// This currently does not happen as anonymous read transactions
13711371
/// are not exposed to modules.
13721372
#[inline]
1373-
pub fn procedure_commit_mut_transaction() -> Result<()> {
1374-
call_no_ret(|| unsafe { raw::procedure_commit_mut_transaction() })
1373+
pub fn procedure_commit_mut_tx() -> Result<()> {
1374+
call_no_ret(|| unsafe { raw::procedure_commit_mut_tx() })
13751375
}
13761376

13771377
/// Aborts a mutable transaction,
@@ -1385,15 +1385,15 @@ pub mod procedure {
13851385
/// Returns an error:
13861386
///
13871387
/// - `TRANSACTION_NOT_ANONYMOUS`,
1388-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
1388+
/// if the transaction was not started in [`procedure_start_mut_tx`].
13891389
/// This can happen if this syscall is erroneously called by a reducer.
13901390
/// The code `NOT_IN_TRANSACTION` does not happen,
13911391
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
13921392
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
13931393
/// This currently does not happen as anonymous read transactions
13941394
/// are not exposed to modules.
13951395
#[inline]
1396-
pub fn procedure_abort_mut_transaction() -> Result<()> {
1397-
call_no_ret(|| unsafe { raw::procedure_abort_mut_transaction() })
1396+
pub fn procedure_abort_mut_tx() -> Result<()> {
1397+
call_no_ret(|| unsafe { raw::procedure_abort_mut_tx() })
13981398
}
13991399
}

crates/bindings/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ impl ReducerContext {
10071007
}
10081008

10091009
/// The context that an anonymous transaction
1010-
/// in [`ProcedureContext::with_transaction`] is provided with.
1010+
/// in [`ProcedureContext::with_tx`] is provided with.
10111011
///
10121012
/// Includes information about the client starting the transaction
10131013
/// and the time of the procedure/reducer,
@@ -1138,10 +1138,10 @@ impl ProcedureContext {
11381138
/// e.g., due to a conflict with a concurrent transaction,
11391139
/// this method will re-invoke `body` with a new transaction in order to retry.
11401140
/// This is done once. On the second failure, a panic will occur.
1141-
pub fn with_transaction<R: IsOk>(&mut self, body: impl Fn(&TxContext) -> R) -> R {
1141+
pub fn with_tx<R: IsOk>(&mut self, body: impl Fn(&TxContext) -> R) -> R {
11421142
let run = || {
11431143
// Start the transaction.
1144-
let timestamp = sys::procedure::procedure_start_mut_transaction().expect(
1144+
let timestamp = sys::procedure::procedure_start_mut_tx().expect(
11451145
"holding `&mut ProcedureContext`, so should not be in a tx already; called manually elsewhere?",
11461146
);
11471147
let timestamp = Timestamp::from_micros_since_unix_epoch(timestamp);
@@ -1154,21 +1154,21 @@ impl ProcedureContext {
11541154

11551155
let mut res = run();
11561156
let abort = || {
1157-
sys::procedure::procedure_abort_mut_transaction()
1158-
.expect("should have a pending mutable anon tx as `procedure_start_mut_transaction` preceded")
1157+
sys::procedure::procedure_abort_mut_tx()
1158+
.expect("should have a pending mutable anon tx as `procedure_start_mut_tx` preceded")
11591159
};
11601160

11611161
// Commit or roll back?
11621162
if res.is_ok() {
1163-
if sys::procedure::procedure_commit_mut_transaction().is_err() {
1163+
if sys::procedure::procedure_commit_mut_tx().is_err() {
11641164
log::warn!("committing anonymous transaction failed");
11651165

11661166
// NOTE(procedure,centril): there's no actual guarantee that `body`
11671167
// does the exact same as the time before, as the timestamps differ
11681168
// and due to interior mutability.
11691169
res = run();
11701170
if res.is_ok() {
1171-
sys::procedure::procedure_commit_mut_transaction().expect("transaction retry failed again")
1171+
sys::procedure::procedure_commit_mut_tx().expect("transaction retry failed again")
11721172
} else {
11731173
abort();
11741174
}

crates/core/src/host/wasm_common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ macro_rules! abi_funcs {
423423

424424
$link_async! {
425425
"spacetime_10.3"::procedure_sleep_until,
426-
"spacetime_10.3"::procedure_start_mut_transaction,
427-
"spacetime_10.3"::procedure_commit_mut_transaction,
428-
"spacetime_10.3"::procedure_abort_mut_transaction,
426+
"spacetime_10.3"::procedure_start_mut_tx,
427+
"spacetime_10.3"::procedure_commit_mut_tx,
428+
"spacetime_10.3"::procedure_abort_mut_tx,
429429
}
430430
};
431431
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl WasmInstanceEnv {
14621462
/// Returns an error:
14631463
///
14641464
/// - `WOULD_BLOCK_TRANSACTION`, if there's already an ongoing transaction.
1465-
pub fn procedure_start_mut_transaction<'caller>(
1465+
pub fn procedure_start_mut_tx<'caller>(
14661466
caller: Caller<'caller, Self>,
14671467
(out,): (WasmPtr<u64>,),
14681468
) -> Fut<'caller, RtResult<u32>> {
@@ -1503,17 +1503,14 @@ impl WasmInstanceEnv {
15031503
/// Returns an error:
15041504
///
15051505
/// - `TRANSACTION_NOT_ANONYMOUS`,
1506-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
1506+
/// if the transaction was not started in [`procedure_start_mut_tx`].
15071507
/// This can happen if this syscall is erroneously called by a reducer.
15081508
/// The code `NOT_IN_TRANSACTION` does not happen,
15091509
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
15101510
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
15111511
/// This currently does not happen as anonymous read transactions
15121512
/// are not exposed to modules.
1513-
pub fn procedure_commit_mut_transaction<'caller>(
1514-
caller: Caller<'caller, Self>,
1515-
(): (),
1516-
) -> Fut<'caller, RtResult<u32>> {
1513+
pub fn procedure_commit_mut_tx<'caller>(caller: Caller<'caller, Self>, (): ()) -> Fut<'caller, RtResult<u32>> {
15171514
Self::async_with_span(
15181515
caller,
15191516
AbiCall::ProcedureCommitMutTransaction,
@@ -1578,17 +1575,14 @@ impl WasmInstanceEnv {
15781575
/// Returns an error:
15791576
///
15801577
/// - `TRANSACTION_NOT_ANONYMOUS`,
1581-
/// if the transaction was not started in [`procedure_start_mut_transaction`].
1578+
/// if the transaction was not started in [`procedure_start_mut_tx`].
15821579
/// This can happen if this syscall is erroneously called by a reducer.
15831580
/// The code `NOT_IN_TRANSACTION` does not happen,
15841581
/// as it is subsumed by `TRANSACTION_NOT_ANONYMOUS`.
15851582
/// - `TRANSACTION_IS_READ_ONLY`, if the pending transaction is read-only.
15861583
/// This currently does not happen as anonymous read transactions
15871584
/// are not exposed to modules.
1588-
pub fn procedure_abort_mut_transaction<'caller>(
1589-
caller: Caller<'caller, Self>,
1590-
(): (),
1591-
) -> Fut<'caller, RtResult<u32>> {
1585+
pub fn procedure_abort_mut_tx<'caller>(caller: Caller<'caller, Self>, (): ()) -> Fut<'caller, RtResult<u32>> {
15921586
Self::async_with_span(caller, AbiCall::ProcedureAbortMutTransaction, |mut caller| async move {
15931587
let (_, env) = Self::mem_env(&mut caller);
15941588

crates/testing/tests/standalone_integration_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn test_calling_a_procedure() {
181181
test_calling_a_procedure_in_module("module-test");
182182
}
183183

184-
fn test_calling_with_transaction_in_module(module_name: &'static str) {
184+
fn test_calling_with_tx_in_module(module_name: &'static str) {
185185
init();
186186

187187
CompiledModule::compile(module_name, CompilationMode::Debug).with_module_async(
@@ -190,7 +190,7 @@ fn test_calling_with_transaction_in_module(module_name: &'static str) {
190190
let json = r#"
191191
{
192192
"CallProcedure": {
193-
"procedure": "with_transaction",
193+
"procedure": "with_tx",
194194
"args": "[]",
195195
"request_id": 0,
196196
"flags": 0
@@ -211,8 +211,8 @@ fn test_calling_with_transaction_in_module(module_name: &'static str) {
211211

212212
#[test]
213213
#[serial]
214-
fn test_calling_with_transaction() {
215-
test_calling_with_transaction_in_module("module-test");
214+
fn test_calling_with_tx() {
215+
test_calling_with_tx_in_module("module-test");
216216
}
217217

218218
/// Invoke the `module-test` module,

modules/module-test/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,6 @@ fn return_value(_ctx: &mut ProcedureContext, foo: u64) -> Baz {
468468
}
469469

470470
#[spacetimedb::procedure]
471-
fn with_transaction(ctx: &mut ProcedureContext) {
472-
ctx.with_transaction(|tx| say_hello(tx));
471+
fn with_tx(ctx: &mut ProcedureContext) {
472+
ctx.with_tx(|tx| say_hello(tx));
473473
}

0 commit comments

Comments
 (0)