Class: XRBP::NodeStore::Backends::NuDB
- Includes:
- Decompressor
- Defined in:
- lib/xrbp/nodestore/backends/nudb.rb
Overview
NuDB nodestore backend, faciliates accessing XRP Ledger data in a NuDB database. This module accommodates for compression used in rippled’s NuDB nodestore backend implementation
Constant Summary collapse
- KEY_SIZE =
32
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#[](key) ⇒ String
Retrieve database value for the specified key.
-
#each ⇒ Object
Iterate over each database key/value pair, invoking callback.
-
#initialize(path) ⇒ NuDB
constructor
A new instance of NuDB.
Methods inherited from DB
#account, #inner_node, #ledger, #ledger_entry, #tx
Constructor Details
#initialize(path) ⇒ NuDB
Returns a new instance of NuDB.
26 27 28 29 30 |
# File 'lib/xrbp/nodestore/backends/nudb.rb', line 26 def initialize(path) @path = path create! open end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/xrbp/nodestore/backends/nudb.rb', line 22 def path @path end |
Instance Method Details
#[](key) ⇒ String
Retrieve database value for the specified key
36 37 38 39 40 |
# File 'lib/xrbp/nodestore/backends/nudb.rb', line 36 def [](key) fetched = @store.fetch(key)[0] return nil if fetched.empty? decompress(fetched) end |
#each ⇒ Object
Iterate over each database key/value pair, invoking callback. During iteration will emit signals specific to the DB types being parsed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/xrbp/nodestore/backends/nudb.rb', line 61 def each dat = File.join(path, "nudb.dat") RuDB::each(dat) do |key, val| val = decompress(val) type, obj = infer_type(val) if type emit type, key, obj else emit :unknown, key, val end # 'mock' iterator iterator = OpenStruct.new(:key => key, :value => val) yield iterator end return self end |