Class: Ethereum::DB::OverlayDB

Inherits:
Object
  • Object
show all
Includes:
BaseDB
Defined in:
lib/ethereum/db/overlay_db.rb

Overview

Used for making temporary objects.

Instance Attribute Summary

Attributes included from BaseDB

#db

Instance Method Summary collapse

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
  @overlay = {}
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

#commitObject



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)
  @overlay[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 @overlay.has_key?(k)
    raise KeyError, k.inspect if @overlay[k].nil?
    return @overlay[k]
  end

  db.get k
end

#has_key?(k) ⇒ Boolean Also known as: include?

Returns:



42
43
44
# File 'lib/ethereum/db/overlay_db.rb', line 42

def has_key?(k)
  @overlay.has_key?(k) ? !@overlay[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)
  @overlay[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