Expand description
Deterministic karma accounting and net settlement.
The crate models the Cocoshiga principle: record contributions, cancel reciprocal obligations, preserve every party’s net position, and emit only the transfers still required for settlement.
A contribution from a giver to a receiver makes the giver a creditor and the receiver a debtor by the recorded number of units.
use karma_cigarette::{Cocoshiga, KarmaLedger};
let mut ledger = KarmaLedger::new();
ledger.record("aya", "ben", 8, "helped with a task")?;
ledger.record("ben", "aya", 3, "returned the favor")?;
let plan = Cocoshiga::settle(&ledger)?;
assert_eq!(plan.transfers()[0].units(), 5);
assert!(plan.is_conserved());Structs§
- Cocoshiga
- Implements the Cocoshiga net-settlement principle.
- Karma
Entry - One contribution recorded in a
KarmaLedger. - Karma
Ledger - An append-only collection of karma entries.
- PartyId
- A stable, non-empty identifier for a party in a ledger.
- Settlement
Plan - A deterministic settlement plan produced from a ledger.
- Settlement
Transfer - A payment required to satisfy a net karma position.
Enums§
- Karma
Error - Validation and arithmetic failures returned by the crate.