Class: Solace::Instructions::ComputeBudget::SetComputeUnitLimitInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::ComputeBudget::SetComputeUnitLimitInstruction
- Defined in:
- lib/solace/instructions/compute_budget/set_compute_unit_limit_instruction.rb
Overview
Instruction for setting the compute unit limit.
This instruction is used to set the maximum number of compute units a transaction may consume. Together with the compute unit price, it determines the priority fee the transaction pays.
Constant Summary collapse
- INSTRUCTION_INDEX =
[2].freeze
Instance Attribute Summary collapse
-
#INSTRUCTION_INDEX ⇒ Object
readonly
Instruction index for the Compute Budget Program's SetComputeUnitLimit instruction.
Class Method Summary collapse
-
.build(units:, program_index:) ⇒ Solace::Instruction
Builds a Solace::Instruction for setting the compute unit limit.
-
.data(units) ⇒ Array<Integer>
Instruction data for a set compute unit limit instruction.
Instance Attribute Details
#INSTRUCTION_INDEX ⇒ Object (readonly)
Instruction index for the Compute Budget Program's SetComputeUnitLimit instruction.
22 |
# File 'lib/solace/instructions/compute_budget/set_compute_unit_limit_instruction.rb', line 22 INSTRUCTION_INDEX = [2].freeze |
Class Method Details
.build(units:, program_index:) ⇒ Solace::Instruction
Builds a Solace::Instruction for setting the compute unit limit
29 30 31 32 33 34 35 |
# File 'lib/solace/instructions/compute_budget/set_compute_unit_limit_instruction.rb', line 29 def self.build(units:, program_index:) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [] ix.data = data(units) end end |
.data(units) ⇒ Array<Integer>
Instruction data for a set compute unit limit instruction
The BufferLayout is:
- [Instruction Index (1 byte)]
- [Compute unit limit (4 bytes little-endian u32)]
45 46 47 |
# File 'lib/solace/instructions/compute_budget/set_compute_unit_limit_instruction.rb', line 45 def self.data(units) INSTRUCTION_INDEX + Solace::Utils::Codecs.encode_le_u32(units).bytes end |