Class: Immudb::Tx
- Inherits:
-
Object
- Object
- Immudb::Tx
- Defined in:
- lib/immudb/tx.rb
Instance Attribute Summary collapse
-
#Alh ⇒ Object
Returns the value of attribute Alh.
-
#BlRoot ⇒ Object
Returns the value of attribute BlRoot.
-
#BlTxID ⇒ Object
Returns the value of attribute BlTxID.
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#htree ⇒ Object
Returns the value of attribute htree.
-
#ID ⇒ Object
Returns the value of attribute ID.
-
#nentries ⇒ Object
Returns the value of attribute nentries.
-
#PrevAlh ⇒ Object
Returns the value of attribute PrevAlh.
-
#Ts ⇒ Object
Returns the value of attribute Ts.
Instance Method Summary collapse
- #build_hash_tree ⇒ Object
- #calc_alh ⇒ Object
- #calc_innerhash ⇒ Object
- #eh ⇒ Object
- #proof(key) ⇒ Object
Instance Attribute Details
#Alh ⇒ Object
Returns the value of attribute Alh.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def Alh @Alh end |
#BlRoot ⇒ Object
Returns the value of attribute BlRoot.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def BlRoot @BlRoot end |
#BlTxID ⇒ Object
Returns the value of attribute BlTxID.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def BlTxID @BlTxID end |
#entries ⇒ Object
Returns the value of attribute entries.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def entries @entries end |
#htree ⇒ Object
Returns the value of attribute htree.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def htree @htree end |
#ID ⇒ Object
Returns the value of attribute ID.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def ID @ID end |
#nentries ⇒ Object
Returns the value of attribute nentries.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def nentries @nentries end |
#PrevAlh ⇒ Object
Returns the value of attribute PrevAlh.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def PrevAlh @PrevAlh end |
#Ts ⇒ Object
Returns the value of attribute Ts.
15 16 17 |
# File 'lib/immudb/tx.rb', line 15 def Ts @Ts end |
Instance Method Details
#build_hash_tree ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/immudb/tx.rb', line 17 def build_hash_tree digests = [] @entries.each do |e| digests << e.digest end @htree.build_with(digests) end |
#calc_alh ⇒ Object
25 26 27 28 29 |
# File 'lib/immudb/tx.rb', line 25 def calc_alh calc_innerhash bi = [@ID].pack("Q>") + @PrevAlh + @InnerHash @Alh = Digest::SHA256.digest(bi) end |
#calc_innerhash ⇒ Object
31 32 33 34 35 |
# File 'lib/immudb/tx.rb', line 31 def calc_innerhash bj = [@Ts, @nentries].pack("Q>L>") + eh bj += [@BlTxID].pack("Q>") + @BlRoot @InnerHash = Digest::SHA256.digest(bj) end |
#eh ⇒ Object
37 38 39 |
# File 'lib/immudb/tx.rb', line 37 def eh @htree.root end |
#proof(key) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/immudb/tx.rb', line 41 def proof(key) kindex = nil # find index of element holding given key @entries.each_with_index do |v, k| if v.key == key kindex = k break end end if kindex.nil? raise KeyError end @htree.inclusion_proof(kindex) end |