-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreversibility.007
More file actions
27 lines (26 loc) · 753 Bytes
/
Copy pathreversibility.007
File metadata and controls
27 lines (26 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath)
--
-- Example: Reversibility blocks.
-- Demonstrates reversible, irreversible, and reverse constructs.
-- Reversible transaction processing
agent TransactionProcessor {
control {
on receive(tx: String) {
reversible {
let balance = debit(account, amount)
send(balance, ledger)
}
irreversible {
let log_entry = log_tx(tx)
send(log_entry, audit)
}
}
on error(e: String) {
reverse {
let restored = credit(account, amount)
send(restored, ledger)
}
}
}
}