assertMessageCanAccommodateSize
Asserts that a transaction message can grow from currentSize to nextSize bytes without
exceeding sizeLimit.
Use it in a custom MessagePacker after appending the next instruction(s) to the message so the transaction planner knows to pack them into another transaction message. It works on sizes rather than messages so that callers who already computed them do not pay for it twice.
Parameters
| Parameter | Type | Description |
|---|---|---|
__namedParameters | { currentSize: number; nextSize: number; sizeLimit: number; } | - |
__namedParameters.currentSize | number | The size of the transaction message before packing the next instruction(s), in bytes. |
__namedParameters.nextSize | number | The size of the transaction message after packing the next instruction(s), in bytes. |
__namedParameters.sizeLimit | number | The maximum size of the transaction message, in bytes. |
Returns
void
Example
Throws
Throws a SolanaError with code
SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN if nextSize exceeds
sizeLimit. The error reports how many bytes were required and how many were free.