-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOverlayDB.h
More file actions
55 lines (43 loc) · 1.33 KB
/
OverlayDB.h
File metadata and controls
55 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2014-2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.
#pragma once
#include <memory>
#include <libdevcore/db.h>
#include <libdevcore/Common.h>
#include <libdevcore/Log.h>
#include <libdevcore/StateCacheDB.h>
namespace dev
{
class OverlayDB: public StateCacheDB
{
public:
//explicit OverlayDB(std::unique_ptr<db::DatabaseFace> _db = nullptr)
// : m_db(_db.release(), [](db::DatabaseFace* db) {
// clog(VerbosityDebug, "overlaydb") << "Closing state DB";
// delete db;
// })
//{}
explicit OverlayDB(std::shared_ptr<db::DatabaseFace> _db = nullptr)
: m_db(_db)
{}
~OverlayDB();
// Copyable
OverlayDB(OverlayDB const&) = default;
OverlayDB& operator=(OverlayDB const&) = default;
// Movable
OverlayDB(OverlayDB&&) = default;
OverlayDB& operator=(OverlayDB&&) = default;
void commit();
void rollback();
std::string lookup(h256 const& _h) const;
bool exists(h256 const& _h) const;
void kill(h256 const& _h);
bytes lookupAux(h256 const& _h) const;
std::shared_ptr<db::DatabaseFace> db() { return m_db; }
std::shared_ptr<db::DatabaseFace> db() const { return m_db; }
private:
using StateCacheDB::clear;
std::shared_ptr<db::DatabaseFace> m_db;
};
}