Class: Ethereum::DB::OverlayDB
- Defined in:
- lib/ethereum/db/overlay_db.rb
Overview
Used for making temporary objects.
Instance Attribute Summary
Attributes inherited from BaseDB
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cleanup(epoch) ⇒ Object
- #commit ⇒ Object
- #commit_refcount_changes(epoch) ⇒ Object
- #dec_refcount(k) ⇒ Object
- #delete(k) ⇒ Object
- #get(k) ⇒ Object
- #has_key?(k) ⇒ Boolean (also: #include?)
- #inc_refcount(k, v) ⇒ Object
-
#initialize(db) ⇒ OverlayDB
constructor
A new instance of OverlayDB.
- #put(k, v) ⇒ Object
- #put_temporarily(k, v) ⇒ Object
- #revert_refcount_changes(epoch) ⇒ Object
Constructor Details
#initialize(db) ⇒ OverlayDB
Returns a new instance of OverlayDB.
10 11 12 13 |
# File 'lib/ethereum/db/overlay_db.rb', line 10 def initialize(db) @db = db = {} end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/ethereum/db/overlay_db.rb', line 46 def ==(other) other.instance_of?(self.class) && db = other.db end |
#cleanup(epoch) ⇒ Object
66 67 68 |
# File 'lib/ethereum/db/overlay_db.rb', line 66 def cleanup(epoch) # do nothing end |
#commit ⇒ Object
37 38 39 |
# File 'lib/ethereum/db/overlay_db.rb', line 37 def commit # do nothing end |
#commit_refcount_changes(epoch) ⇒ Object
62 63 64 |
# File 'lib/ethereum/db/overlay_db.rb', line 62 def commit_refcount_changes(epoch) # do nothing end |
#dec_refcount(k) ⇒ Object
54 55 56 |
# File 'lib/ethereum/db/overlay_db.rb', line 54 def dec_refcount(k) # do nothing end |
#delete(k) ⇒ Object
33 34 35 |
# File 'lib/ethereum/db/overlay_db.rb', line 33 def delete(k) [k] = nil end |
#get(k) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/ethereum/db/overlay_db.rb', line 15 def get(k) if .has_key?(k) raise KeyError, k.inspect if [k].nil? return [k] end db.get k end |
#has_key?(k) ⇒ Boolean Also known as: include?
41 42 43 |
# File 'lib/ethereum/db/overlay_db.rb', line 41 def has_key?(k) .has_key?(k) ? ![k].nil? : db.has_key?(k) end |
#inc_refcount(k, v) ⇒ Object
50 51 52 |
# File 'lib/ethereum/db/overlay_db.rb', line 50 def inc_refcount(k, v) put k, v end |
#put(k, v) ⇒ Object
24 25 26 |
# File 'lib/ethereum/db/overlay_db.rb', line 24 def put(k, v) [k] = v end |
#put_temporarily(k, v) ⇒ Object
28 29 30 31 |
# File 'lib/ethereum/db/overlay_db.rb', line 28 def put_temporarily(k, v) inc_refcount k, v dec_refcount k end |
#revert_refcount_changes(epoch) ⇒ Object
58 59 60 |
# File 'lib/ethereum/db/overlay_db.rb', line 58 def revert_refcount_changes(epoch) # do nothing end |