Meshpocalypse Semantic
    Preparing search index...

    Function chargeToHierarchy

    • Charge tokens to a budget and roll up through the entire delegation chain.

      Increments mesh:spentTokens on the given budget, then walks up via mesh:parentBudget, incrementing spentTokens at each level until there is no parent. Uses the same optimistic-concurrency pattern as enforceTokenBudget: each level is updated atomically (DELETE old / INSERT new matched by current value). Retries on BudgetConcurrencyError up to 3 times per level.

      Parameters

      • budgetId: string

        Budget to charge (IRI key — will roll up to parent)

      • tokens: number

        Number of tokens to charge (positive integer)

      • config: AiGatewayConfig

        Gateway configuration

      Returns Promise<void>

      If chain depth exceeds MAX_DELEGATION_DEPTH (10)

      If the starting budget does not exist

      If all retries at a level are exhausted

      If budgetId is unsafe or tokens is invalid