-
Notifications
You must be signed in to change notification settings - Fork 0
The ledger, and the one amendment to a frozen protocol #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9587e69
f4188dc
a674f1f
a92dec1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| from ...effect import DEFAULT_LEASE, EffectRecord, EffectState, Reservation | ||
| from ...errors import NotExecuted | ||
| from ...receipt import Event | ||
| from ...state import ClockSkew, DelegationRecord, StateStore | ||
| from ...state import Charge, ClockSkew, DelegationRecord, StateStore | ||
| from .backends import SQLiteBackend, StoreBackend | ||
|
|
||
|
|
||
|
|
@@ -87,7 +87,11 @@ class _TwoWinners(_Wrapped): | |
| """Drops the uniqueness check: every contender reserves.""" | ||
|
|
||
| def reserve_effect( | ||
| self, effect_key: str, action_id: str, lease: timedelta = DEFAULT_LEASE | ||
| self, | ||
| effect_key: str, | ||
| action_id: str, | ||
| lease: timedelta = DEFAULT_LEASE, | ||
| charges: tuple[Charge, ...] = (), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Preserve non-empty
Forward 🤖 Prompt for AI Agents |
||
| ) -> Reservation: | ||
| now = datetime.now(tz=None).astimezone() | ||
| return Reservation( | ||
|
|
@@ -100,7 +104,11 @@ class _ReleasesAnExpiredLease(_Wrapped): | |
| `AMBIGUOUS` and refusing (`v0.1 §5.3 E3`).""" | ||
|
|
||
| def reserve_effect( | ||
| self, effect_key: str, action_id: str, lease: timedelta = DEFAULT_LEASE | ||
| self, | ||
| effect_key: str, | ||
| action_id: str, | ||
| lease: timedelta = DEFAULT_LEASE, | ||
| charges: tuple[Charge, ...] = (), | ||
| ) -> Reservation: | ||
| record = self._inner.get_effect(effect_key) | ||
| if record is not None and record.lease_expires_at is not None: | ||
|
|
@@ -126,7 +134,11 @@ class _RefusesWithTheWrongError(_Wrapped): | |
| """ | ||
|
|
||
| def reserve_effect( | ||
| self, effect_key: str, action_id: str, lease: timedelta = DEFAULT_LEASE | ||
| self, | ||
| effect_key: str, | ||
| action_id: str, | ||
| lease: timedelta = DEFAULT_LEASE, | ||
| charges: tuple[Charge, ...] = (), | ||
| ) -> Reservation: | ||
| try: | ||
| return self._inner.reserve_effect(effect_key, action_id, lease) | ||
|
|
@@ -158,9 +170,10 @@ def consume_approval_and_reserve( | |
| effect_key: str, | ||
| action_id: str, | ||
| lease: timedelta = DEFAULT_LEASE, | ||
| charges: tuple[Charge, ...] = (), | ||
| ) -> Any: | ||
| approval = self._inner.consume_approval(approval_id, action_hash) | ||
| reservation = self._inner.reserve_effect(effect_key, action_id, lease) | ||
| reservation = self._inner.reserve_effect(effect_key, action_id, lease, charges) | ||
| return approval, reservation | ||
|
|
||
|
|
||
|
|
@@ -274,7 +287,11 @@ def __init__(self, inner: StateStore) -> None: | |
| self._resolvers = {} | ||
|
|
||
| def reserve_effect( | ||
| self, effect_key: str, action_id: str, lease: timedelta = DEFAULT_LEASE | ||
| self, | ||
| effect_key: str, | ||
| action_id: str, | ||
| lease: timedelta = DEFAULT_LEASE, | ||
| charges: tuple[Charge, ...] = (), | ||
| ) -> Reservation: | ||
| before = self._inner.get_effect(effect_key) | ||
| reservation = self._inner.reserve_effect(effect_key, action_id, lease) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the public API table contiguous.
This paragraph terminates the Markdown table before the remaining API rows. Move it after the
Consumptionrow at Line 1623.🤖 Prompt for AI Agents