Class: Sigma::BoxSelection

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/box_selection.rb

Overview

Selected boxes with change boxes. Instances of this class are created by SimpleBoxSelector.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



18
19
20
# File 'lib/sigma/box_selection.rb', line 18

def pointer
  @pointer
end

Class Method Details

.create(ergo_boxes:, change_ergo_boxes:) ⇒ BoxSelection

Create a selection to inject custom select algorithms

Parameters:

Returns:



24
25
26
27
28
# File 'lib/sigma/box_selection.rb', line 24

def self.create(ergo_boxes:, change_ergo_boxes:)
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_box_selection_new(ergo_boxes.pointer, change_ergo_boxes.pointer, pointer)
  init(pointer)
end

.with_raw_pointer(pointer) ⇒ BoxSelection

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing BoxSelection Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



34
35
36
# File 'lib/sigma/box_selection.rb', line 34

def self.with_raw_pointer(pointer)
  init(pointer)
end

Instance Method Details

#==(bs_two) ⇒ bool

Equality check between two BoxSelections

Parameters:

Returns:

  • (bool)


57
58
59
# File 'lib/sigma/box_selection.rb', line 57

def ==(bs_two)
  ergo_lib_box_selection_eq(self.pointer, bs_two.pointer)
end

#get_boxesErgoBoxes

Selected Boxes to spend as transaction inputs

Returns:



40
41
42
43
44
# File 'lib/sigma/box_selection.rb', line 40

def get_boxes
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_box_selection_boxes(self.pointer, pointer)
  Sigma::ErgoBoxes.with_raw_pointer(pointer)
end

#get_change_boxesErgoBoxAssetsDataList

Selected Boxes to use as change



48
49
50
51
52
# File 'lib/sigma/box_selection.rb', line 48

def get_change_boxes
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_box_selection_change(self.pointer, pointer)
  Sigma::ErgoBoxAssetsDataList.with_raw_pointer(pointer)
end