Class: Sigma::PoPowHeader

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



122
123
124
# File 'lib/sigma/nipopow.rb', line 122

def pointer
  @pointer
end

Class Method Details

.with_json(json) ⇒ PoPowHeader

Create from json

Parameters:

  • json (String)

Returns:



127
128
129
130
131
132
# File 'lib/sigma/nipopow.rb', line 127

def self.with_json(json)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_popow_header_from_json(json, pointer)
  Util.check_error!(error)
  init(pointer)
end

Instance Method Details

#==(other_header) ⇒ bool

Equality check

Parameters:

Returns:

  • (bool)


167
168
169
# File 'lib/sigma/nipopow.rb', line 167

def ==(other_header)
  ergo_lib_po_pow_header_eq(self.pointer, other_header.pointer)
end

#get_headerBlockHeader

Get header

Returns:



148
149
150
151
152
153
# File 'lib/sigma/nipopow.rb', line 148

def get_header
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_popow_header_get_header(self.pointer, pointer)
  Util.check_error!(error)
  BlockHeader.with_raw_pointer(pointer)
end

Get interlinks

Returns:



157
158
159
160
161
162
# File 'lib/sigma/nipopow.rb', line 157

def get_interlinks
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_popow_header_get_interlinks(self.pointer, pointer)
  Util.check_error!(error)
  BlockIds.with_raw_pointer(pointer)
end

#to_jsonString

JSON representation

Returns:

  • (String)


136
137
138
139
140
141
142
143
144
# File 'lib/sigma/nipopow.rb', line 136

def to_json
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_popow_header_to_json(self.pointer, s_ptr)
  Util.check_error!(error)
  s_ptr = s_ptr.read_pointer()
  str = s_ptr.read_string().force_encoding('UTF-8')
  Util.ergo_lib_delete_string(s_ptr)
  str
end