Class: Sigma::SimpleBoxSelector
- Inherits:
-
Object
- Object
- Sigma::SimpleBoxSelector
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/box_selection.rb
Overview
Naive box selector, collects inputs until target balace is reached
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.create ⇒ SimpleBoxSelector
Create an empty SimpleBoxSelector.
-
.with_raw_pointer(pointer) ⇒ SimpleBoxSelector
Takes ownership of an existing SimpleBoxSelector Pointer.
Instance Method Summary collapse
-
#select(inputs:, target_balance:, target_tokens:) ⇒ BoxSelection
Selects inputs to satisfy target balance and tokens.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
84 85 86 |
# File 'lib/sigma/box_selection.rb', line 84 def pointer @pointer end |
Class Method Details
.create ⇒ SimpleBoxSelector
Create an empty SimpleBoxSelector
88 89 90 91 92 |
# File 'lib/sigma/box_selection.rb', line 88 def self.create pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_simple_box_selector_new(pointer) init(pointer) end |
.with_raw_pointer(pointer) ⇒ SimpleBoxSelector
Note:
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing SimpleBoxSelector Pointer.
116 117 118 |
# File 'lib/sigma/box_selection.rb', line 116 def self.with_raw_pointer(pointer) init(pointer) end |
Instance Method Details
#select(inputs:, target_balance:, target_tokens:) ⇒ BoxSelection
Selects inputs to satisfy target balance and tokens
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/sigma/box_selection.rb', line 99 def select(inputs:, target_balance:, target_tokens:) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_simple_box_selector_select( self.pointer, inputs.pointer, target_balance.pointer, target_tokens.pointer, pointer ) Util.check_error!(error) Sigma::BoxSelection.with_raw_pointer(pointer) end |