Class: Reth::LevelDBService
- Inherits:
-
DEVp2p::Service
- Object
- DEVp2p::Service
- Reth::LevelDBService
- Defined in:
- lib/reth/leveldb_service.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
implement DB::BaseDB interface.
Instance Method Summary collapse
- #cleanup(epoch) ⇒ Object
- #commit ⇒ Object
- #commit_refcount_changes(epoch) ⇒ Object
- #dec_refcount(k) ⇒ Object
- #delete(k) ⇒ Object
- #get(k) ⇒ Object
- #inc_refcount(k, v) ⇒ Object
- #include?(k) ⇒ Boolean (also: #has_key?)
-
#initialize(app) ⇒ LevelDBService
constructor
A new instance of LevelDBService.
- #put(k, v) ⇒ Object
- #put_temporarily(k, v) ⇒ Object
- #revert_refcount_changes(epoch) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(app) ⇒ LevelDBService
Returns a new instance of LevelDBService.
10 11 12 13 |
# File 'lib/reth/leveldb_service.rb', line 10 def initialize(app) super(app) @db = DB::LevelDB.new File.join(app.config[:data_dir], 'leveldb') end |
Instance Attribute Details
#db ⇒ Object (readonly)
implement DB::BaseDB interface
8 9 10 |
# File 'lib/reth/leveldb_service.rb', line 8 def db @db end |
Instance Method Details
#cleanup(epoch) ⇒ Object
62 63 64 |
# File 'lib/reth/leveldb_service.rb', line 62 def cleanup(epoch) # do nothing end |
#commit ⇒ Object
33 34 35 |
# File 'lib/reth/leveldb_service.rb', line 33 def commit @db.commit end |
#commit_refcount_changes(epoch) ⇒ Object
58 59 60 |
# File 'lib/reth/leveldb_service.rb', line 58 def commit_refcount_changes(epoch) # do nothing end |
#dec_refcount(k) ⇒ Object
50 51 52 |
# File 'lib/reth/leveldb_service.rb', line 50 def dec_refcount(k) # do nothing end |
#delete(k) ⇒ Object
37 38 39 |
# File 'lib/reth/leveldb_service.rb', line 37 def delete(k) @db.delete(k) end |
#get(k) ⇒ Object
23 24 25 26 27 |
# File 'lib/reth/leveldb_service.rb', line 23 def get(k) @db.get(k) rescue KeyError nil end |
#inc_refcount(k, v) ⇒ Object
46 47 48 |
# File 'lib/reth/leveldb_service.rb', line 46 def inc_refcount(k, v) put(k, v) end |
#include?(k) ⇒ Boolean Also known as: has_key?
41 42 43 |
# File 'lib/reth/leveldb_service.rb', line 41 def include?(k) @db.include?(k) end |
#put(k, v) ⇒ Object
29 30 31 |
# File 'lib/reth/leveldb_service.rb', line 29 def put(k, v) @db.put(k, v) end |
#put_temporarily(k, v) ⇒ Object
66 67 68 69 |
# File 'lib/reth/leveldb_service.rb', line 66 def put_temporarily(k, v) inc_refcount(k, v) dec_refcount(k) end |
#revert_refcount_changes(epoch) ⇒ Object
54 55 56 |
# File 'lib/reth/leveldb_service.rb', line 54 def revert_refcount_changes(epoch) # do nothing end |
#start ⇒ Object
15 16 17 |
# File 'lib/reth/leveldb_service.rb', line 15 def start # do nothing end |
#stop ⇒ Object
19 20 21 |
# File 'lib/reth/leveldb_service.rb', line 19 def stop # do nothing end |