Class: Ethereum::DB::OverlayDB

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

Overview

Used for making temporary objects.

Instance Attribute Summary

Attributes inherited from BaseDB

#db

Instance Method Summary collapse

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

#commitObject



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)
  @overlay[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 @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:

  • (Boolean)


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

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