Class: Ethereum::DB::OverlayDB
- Includes:
- BaseDB
- Defined in:
- lib/ethereum/db/overlay_db.rb
Overview
Used for making temporary objects.
Instance Attribute Summary
Attributes included 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.
11 12 13 14 |
# File 'lib/ethereum/db/overlay_db.rb', line 11 def initialize(db) @db = db = {} end |
Instance Method Details
#==(other) ⇒ Object
47 48 49 |
# File 'lib/ethereum/db/overlay_db.rb', line 47 def ==(other) other.instance_of?(self.class) && db = other.db end |
#cleanup(epoch) ⇒ Object
67 68 69 |
# File 'lib/ethereum/db/overlay_db.rb', line 67 def cleanup(epoch) # do nothing end |
#commit ⇒ Object
38 39 40 |
# File 'lib/ethereum/db/overlay_db.rb', line 38 def commit # do nothing end |
#commit_refcount_changes(epoch) ⇒ Object
63 64 65 |
# File 'lib/ethereum/db/overlay_db.rb', line 63 def commit_refcount_changes(epoch) # do nothing end |
#dec_refcount(k) ⇒ Object
55 56 57 |
# File 'lib/ethereum/db/overlay_db.rb', line 55 def dec_refcount(k) # do nothing end |
#delete(k) ⇒ Object
34 35 36 |
# File 'lib/ethereum/db/overlay_db.rb', line 34 def delete(k) [k] = nil end |
#get(k) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ethereum/db/overlay_db.rb', line 16 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?
42 43 44 |
# File 'lib/ethereum/db/overlay_db.rb', line 42 def has_key?(k) .has_key?(k) ? ![k].nil? : db.has_key?(k) end |
#inc_refcount(k, v) ⇒ Object
51 52 53 |
# File 'lib/ethereum/db/overlay_db.rb', line 51 def inc_refcount(k, v) put k, v end |
#put(k, v) ⇒ Object
25 26 27 |
# File 'lib/ethereum/db/overlay_db.rb', line 25 def put(k, v) [k] = v end |
#put_temporarily(k, v) ⇒ Object
29 30 31 32 |
# File 'lib/ethereum/db/overlay_db.rb', line 29 def put_temporarily(k, v) inc_refcount k, v dec_refcount k end |
#revert_refcount_changes(epoch) ⇒ Object
59 60 61 |
# File 'lib/ethereum/db/overlay_db.rb', line 59 def revert_refcount_changes(epoch) # do nothing end |