Fabcoin Core  0.16.2
P2P Digital Currency
OverlayDB.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #pragma once
23 
24 #include <memory>
25 #include <libdevcore/db.h>
26 #include <libdevcore/Common.h>
27 #include <libdevcore/Log.h>
28 #include <libdevcore/MemoryDB.h>
29 
30 namespace dev
31 {
32 
33 class OverlayDB: public MemoryDB
34 {
35 public:
36  OverlayDB(ldb::DB* _db = nullptr): m_db(_db) {}
37  ~OverlayDB();
38 
39  ldb::DB* db() const { return m_db.get(); }
40 
41  void commit();
42  void rollback();
43 
44  std::string lookup(h256 const& _h) const;
45  bool exists(h256 const& _h) const;
46  void kill(h256 const& _h);
47  bool deepkill(h256 const& _h);
48 
49  bytes lookupAux(h256 const& _h) const;
50 
51 private:
52  using MemoryDB::clear;
53 
54  std::shared_ptr<ldb::DB> m_db;
55 
56  ldb::ReadOptions m_readOptions;
57  ldb::WriteOptions m_writeOptions;
58 };
59 
60 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Definition: util.h:95
bool exists(h256 const &_h) const
Definition: OverlayDB.cpp:128
std::string lookup(h256 const &_h) const
Definition: OverlayDB.cpp:120
ldb::ReadOptions m_readOptions
Definition: OverlayDB.h:56
std::vector< byte > bytes
Definition: Common.h:75
bytes lookupAux(h256 const &_h) const
Definition: OverlayDB.cpp:98
ldb::WriteOptions m_writeOptions
Definition: OverlayDB.h:57
ldb::DB * db() const
Definition: OverlayDB.h:39
void clear()
Definition: MemoryDB.h:51
void kill(h256 const &_h)
Definition: OverlayDB.cpp:138
bool deepkill(h256 const &_h)
Definition: OverlayDB.cpp:158
std::shared_ptr< ldb::DB > m_db
Definition: OverlayDB.h:54
OverlayDB(ldb::DB *_db=nullptr)
Definition: OverlayDB.h:36