Skip to main content

Crate karma_cigarette

Crate karma_cigarette 

Source
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.
KarmaEntry
One contribution recorded in a KarmaLedger.
KarmaLedger
An append-only collection of karma entries.
PartyId
A stable, non-empty identifier for a party in a ledger.
SettlementPlan
A deterministic settlement plan produced from a ledger.
SettlementTransfer
A payment required to satisfy a net karma position.

Enums§

KarmaError
Validation and arithmetic failures returned by the crate.