Class: Sigma::NipopowVerifier

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

Overview

A verifier for PoPoW proofs. During its lifetime, it processes many proofs with the aim of deducing at any given point what is the best (sub)chain rooted at the specified genesis.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



73
74
75
# File 'lib/sigma/nipopow.rb', line 73

def pointer
  @pointer
end

Class Method Details

.create(genesis_block_id) ⇒ NipopowVerifier

Create new instance

Parameters:

Returns:



78
79
80
81
82
# File 'lib/sigma/nipopow.rb', line 78

def self.create(genesis_block_id)
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_nipopow_verifier_new(genesis_block_id.pointer, pointer)
  init(pointer)
end

Instance Method Details

#best_chainBlockHeaders

Returns chain of ‘BlockHeader`s from the best proof.

Returns:



86
87
88
89
90
# File 'lib/sigma/nipopow.rb', line 86

def best_chain
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_nipopow_verifier_best_chain(self.pointer, pointer)
  BlockHeaders.with_raw_pointer(pointer)
end

#process(proof) ⇒ Object

Process given proof

Parameters:



94
95
96
97
# File 'lib/sigma/nipopow.rb', line 94

def process(proof)
  error = ergo_lib_nipopow_verifier_process(self.pointer, proof.pointer)
  Util.check_error!(error)
end