Trait PoolOps

Source
pub trait PoolOps<Proprietor, Pallet>
where Pallet: LazyBalance<Asset = <Pallet as InspectAsset<Proprietor>>::Asset, Variant = Pallet::Position, Id = Pallet::Digest> + PoolVariant<Proprietor>,
{ type PoolBalance; // Required methods fn release_pool( reason: &Pallet::Reason, pool_of: &Pallet::Digest, ) -> Result<Self::PoolBalance, DispatchError>; fn recover_pool( reason: &Pallet::Reason, pool_of: &Pallet::Digest, balance: &Self::PoolBalance, ) -> DispatchResult; fn remove_pool_slot( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, slot_of: &Pallet::Digest, ) -> DispatchResult; fn set_pool_slot( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, slot_of: &Pallet::Digest, shares: Pallet::Shares, variant: &Pallet::Position, ) -> DispatchResult; }
Expand description

Defines operational behavior for managing pooled balances within a commitment system.

A PoolOps implementation extends PoolVariant to provide concrete management logic for a proprietor’s pooled balances, where a pool may act as a single committing authority maintaining aggregate or managed funds.

Unlike indexes (which represent discrete digests committed on behalf of a proprietor), pools aggregate balances and resolve them collectively, acting as a unified resource manager.

This trait defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking these functions.

§Generics

  • Proprietor - the entity (e.g. account, vault, or manager) controlling the asset.
  • Pallet - the public struct implementing Commitment traits and LazyBalance, ensuring consistent asset accounting across the commitment system.

Required Associated Types§

Source

type PoolBalance

The balance type associated with the pool.

Required Methods§

Source

fn release_pool( reason: &Pallet::Reason, pool_of: &Pallet::Digest, ) -> Result<Self::PoolBalance, DispatchError>

Releases a pool’s balance, resetting it to its default state.

Releasing a pool means resolving all active commit digests from this single balance, similar in concept to resolving a commit.

  • The release-recovery should be immediate at the calling site - safety must be ensured by the caller.
  • Pools differ from indexes: while indexes resolve multiple digests per proprietor, pools resolve from a single managed balance representing aggregated commitments.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Returns
  • Ok(PoolBalance) containing the resolved pool balance
  • Err(DispatchError) if the release operation fails
Source

fn recover_pool( reason: &Pallet::Reason, pool_of: &Pallet::Digest, balance: &Self::PoolBalance, ) -> DispatchResult

Recovers a pool’s state after a prior release via PoolOps::release_pool.

This function restores the pool’s state following balance mutation or reconciliation. Should only be invoked after the pool has been released via PoolOps::release_pool.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Returns
  • Ok(()) if the pool state was successfully recovered
  • Err(DispatchError) if recovery fails
Source

fn remove_pool_slot( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, slot_of: &Pallet::Digest, ) -> DispatchResult

Removes a slot from a pool and updates the pool’s state accordingly.

This operation ensures that:

  • The slot represented by slot_of is removed from the pool.
  • The pool’s collective balance is released and then recovered to reflect the updated state after removal.

Automatically updates the pool’s internal representation of managed funds.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Returns
  • Ok(()) if the slot was successfully removed and pool state updated
  • Err(DispatchError) if the operation fails
Source

fn set_pool_slot( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, slot_of: &Pallet::Digest, shares: Pallet::Shares, variant: &Pallet::Position, ) -> DispatchResult

Sets or updates a slot within a pool and synchronizes the pool’s state.

This operation may:

  • Add a new slot to the pool.
  • Update an existing slot’s shares or variant.
  • Trigger a pool release and recovery cycle to ensure the pool’s balance reflects the new slot configuration.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Behavior
  • Ensures slot state consistency within the pool.
  • Used for slot creation, update, or reallocation of pool shares.
§Returns
  • Ok(()) if the slot was successfully set and pool state synchronized
  • Err(DispatchError) if the operation fails

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Config<I>, I: 'static> PoolOps<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implementation of PoolOps for the pallet, defining how pools slots are queried, inserted, updated, or removed within a given index digest.

Each function operates on the pool-slot composition layer - maintaining relationships between an pool digest and its subordinate slot digests.