Class: Reth::DBService
- Inherits:
-
DEVp2p::Service
- Object
- DEVp2p::Service
- Reth::DBService
- Includes:
- BaseDB
- Defined in:
- lib/reth/db_service.rb
Instance Method Summary collapse
- #cleanup(epoch) ⇒ Object
- #commit ⇒ Object
- #commit_refcount_changes(epoch) ⇒ Object
- #db ⇒ Object
- #dec_refcount(k) ⇒ Object
- #delete(k) ⇒ Object
- #get(k) ⇒ Object
- #inc_refcount(k, v) ⇒ Object
- #include?(k) ⇒ Boolean (also: #has_key?)
-
#initialize(app) ⇒ DBService
constructor
A new instance of DBService.
- #put(k, v) ⇒ Object
- #put_temporarily(k, v) ⇒ Object
- #revert_refcount_changes(epoch) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(app) ⇒ DBService
Returns a new instance of DBService.
15 16 17 18 |
# File 'lib/reth/db_service.rb', line 15 def initialize(app) super(app) @db_service = LevelDBService.new(app) end |
Instance Method Details
#cleanup(epoch) ⇒ Object
79 80 81 |
# File 'lib/reth/db_service.rb', line 79 def cleanup(epoch) # do nothing end |
#commit ⇒ Object
45 46 47 |
# File 'lib/reth/db_service.rb', line 45 def commit @db_service.async.commit end |
#commit_refcount_changes(epoch) ⇒ Object
75 76 77 |
# File 'lib/reth/db_service.rb', line 75 def commit_refcount_changes(epoch) # do nothing end |
#db ⇒ Object
28 29 30 |
# File 'lib/reth/db_service.rb', line 28 def db @db_service.db end |
#dec_refcount(k) ⇒ Object
67 68 69 |
# File 'lib/reth/db_service.rb', line 67 def dec_refcount(k) # do nothing end |
#delete(k) ⇒ Object
49 50 51 |
# File 'lib/reth/db_service.rb', line 49 def delete(k) @db_service.async.delete(k) end |
#get(k) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/reth/db_service.rb', line 32 def get(k) ivar = @db_service.await.get(k) if ivar.rejected? raise ivar.reason else ivar.value end end |
#inc_refcount(k, v) ⇒ Object
63 64 65 |
# File 'lib/reth/db_service.rb', line 63 def inc_refcount(k, v) put(k, v) end |
#include?(k) ⇒ Boolean Also known as: has_key?
53 54 55 56 57 58 59 60 |
# File 'lib/reth/db_service.rb', line 53 def include?(k) ivar = @db_service.await.include?(k) if ivar.rejected? raise ivar.reason else ivar.value end end |
#put(k, v) ⇒ Object
41 42 43 |
# File 'lib/reth/db_service.rb', line 41 def put(k, v) @db_service.async.put(k, v) end |
#put_temporarily(k, v) ⇒ Object
83 84 85 86 |
# File 'lib/reth/db_service.rb', line 83 def put_temporarily(k, v) inc_refcount(k, v) dec_refcount(k) end |
#revert_refcount_changes(epoch) ⇒ Object
71 72 73 |
# File 'lib/reth/db_service.rb', line 71 def revert_refcount_changes(epoch) # do nothing end |
#start ⇒ Object
20 21 22 |
# File 'lib/reth/db_service.rb', line 20 def start @db_service.async.start end |
#stop ⇒ Object
24 25 26 |
# File 'lib/reth/db_service.rb', line 24 def stop @db_service.async.stop end |