Class: Reth::LevelDBService

Inherits:
DEVp2p::Service
  • Object
show all
Defined in:
lib/reth/leveldb_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ LevelDBService

Returns a new instance of LevelDBService.



10
11
12
13
# File 'lib/reth/leveldb_service.rb', line 10

def initialize(app)
  super(app)
  @db = DB::LevelDB.new File.join(app.config[:data_dir], 'leveldb')
end

Instance Attribute Details

#dbObject (readonly)

implement DB::BaseDB interface



8
9
10
# File 'lib/reth/leveldb_service.rb', line 8

def db
  @db
end

Instance Method Details

#cleanup(epoch) ⇒ Object



62
63
64
# File 'lib/reth/leveldb_service.rb', line 62

def cleanup(epoch)
  # do nothing
end

#commitObject



33
34
35
# File 'lib/reth/leveldb_service.rb', line 33

def commit
  @db.commit
end

#commit_refcount_changes(epoch) ⇒ Object



58
59
60
# File 'lib/reth/leveldb_service.rb', line 58

def commit_refcount_changes(epoch)
  # do nothing
end

#dec_refcount(k) ⇒ Object



50
51
52
# File 'lib/reth/leveldb_service.rb', line 50

def dec_refcount(k)
  # do nothing
end

#delete(k) ⇒ Object



37
38
39
# File 'lib/reth/leveldb_service.rb', line 37

def delete(k)
  @db.delete(k)
end

#get(k) ⇒ Object



23
24
25
26
27
# File 'lib/reth/leveldb_service.rb', line 23

def get(k)
  @db.get(k)
rescue KeyError
  nil
end

#inc_refcount(k, v) ⇒ Object



46
47
48
# File 'lib/reth/leveldb_service.rb', line 46

def inc_refcount(k, v)
  put(k, v)
end

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

Returns:

  • (Boolean)


41
42
43
# File 'lib/reth/leveldb_service.rb', line 41

def include?(k)
  @db.include?(k)
end

#put(k, v) ⇒ Object



29
30
31
# File 'lib/reth/leveldb_service.rb', line 29

def put(k, v)
  @db.put(k, v)
end

#put_temporarily(k, v) ⇒ Object



66
67
68
69
# File 'lib/reth/leveldb_service.rb', line 66

def put_temporarily(k, v)
  inc_refcount(k, v)
  dec_refcount(k)
end

#revert_refcount_changes(epoch) ⇒ Object



54
55
56
# File 'lib/reth/leveldb_service.rb', line 54

def revert_refcount_changes(epoch)
  # do nothing
end

#startObject



15
16
17
# File 'lib/reth/leveldb_service.rb', line 15

def start
  # do nothing
end

#stopObject



19
20
21
# File 'lib/reth/leveldb_service.rb', line 19

def stop
  # do nothing
end