Attribute Macro frame_support_procedural::transactional
source · #[transactional]
Expand description
Execute the annotated function in a new storage transaction.
The return type of the annotated function must be Result
. All changes to storage performed
by the annotated function are discarded if it returns Err
, or committed if Ok
.
Example
#[transactional]
fn value_commits(v: u32) -> result::Result<u32, &'static str> {
Value::set(v);
Ok(v)
}
#[transactional]
fn value_rollbacks(v: u32) -> result::Result<u32, &'static str> {
Value::set(v);
Err("nah")
}