Class: Immudb::Tx
- Inherits:
-
Object
- Object
- Immudb::Tx
- Defined in:
- lib/immudb/tx.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#header ⇒ Object
Returns the value of attribute header.
-
#htree ⇒ Object
Returns the value of attribute htree.
Instance Method Summary collapse
- #build_hash_tree ⇒ Object
- #index_of(key) ⇒ Object
-
#initialize ⇒ Tx
constructor
A new instance of Tx.
- #proof(key) ⇒ Object
- #tx_entry_digest ⇒ Object
Constructor Details
#initialize ⇒ Tx
Returns a new instance of Tx.
17 18 19 20 21 |
# File 'lib/immudb/tx.rb', line 17 def initialize @header = nil @entries = nil @htree = nil end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def entries @entries end |
#header ⇒ Object
Returns the value of attribute header.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def header @header end |
#htree ⇒ Object
Returns the value of attribute htree.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def htree @htree end |
Instance Method Details
#build_hash_tree ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/immudb/tx.rb', line 33 def build_hash_tree digests = [] tx_entry_digest = self.tx_entry_digest @entries.each do |e| digests << tx_entry_digest.call(e) end @htree.build_with(digests) root = @htree.root @header.eh = root end |
#index_of(key) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/immudb/tx.rb', line 44 def index_of(key) kindex = nil @entries.each_with_index do |v, k| if v.key == key kindex = k break end end if kindex.nil? raise VerificationError end kindex end |
#proof(key) ⇒ Object
58 59 60 61 |
# File 'lib/immudb/tx.rb', line 58 def proof(key) kindex = index_of(key) htree.inclusion_proof(kindex) end |
#tx_entry_digest ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/immudb/tx.rb', line 23 def tx_entry_digest if @header.version == 0 method(:tx_entry_digest_v1_1) elsif @header.version == 1 method(:tx_entry_digest_v1_2) else raise VerificationError end end |