Expand description
Remaining-accounts accessor with strict and passthrough modes.
The declared context validates exactly ACCOUNT_COUNT accounts.
Any accounts beyond that index are “remaining”: pool participants,
keeper bot recipients, arbitrary fanout destinations, remainder
destinations for sweeps, and so on. Hopper exposes two ways to
consume them.
§Strict mode
Default. The accessor rejects any remaining account whose address matches a previously seen account (either declared or already yielded). Protects against accidental double-spending when a caller tries to alias one slot into two different roles.
let rem = ctx.remaining_accounts();
for maybe_acc in rem.iter() {
let acc = maybe_acc?; // errors on duplicate
// ...
}§Passthrough mode
Opt-in. Preserves duplicates verbatim. Use when the caller is expected to pass the same account in multiple roles (batched CPI fan-in, for example).
let rem = ctx.remaining_accounts_passthrough();Both modes are O(n) with no heap and no syscalls. Strict mode keeps a small const-sized seen-address cache sized at 64; past that, it falls back to a linear scan of the declared slice plus the yielded-view cursor.
Structs§
- Remaining
Accounts - Zero-allocation remaining-accounts view.
- Remaining
Iter - Iterator yielded by
RemainingAccounts::iter.
Enums§
- Remaining
Error - Error surface for the remaining-accounts accessor.
- Remaining
Mode - Duplicate-handling policy for a
RemainingAccountsview.
Constants§
- MAX_
REMAINING_ ACCOUNTS - Upper bound on remaining-account iterator length. Matches Quasar’s
MAX_REMAINING_ACCOUNTSso programs porting from one framework to the other see the same ceiling. Exceeding this returns an error rather than risking unbounded stack usage in the seen-address cache.
Functions§
- strict
- Ergonomic fall-through used by the proc-macro codegen when the user wants to just burn through remaining accounts without a mode.