Ethereum  PoC-8
The C++ Implementation of Ethereum
StateImporter.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 */
21 #pragma once
22 
23 #include <libdevcore/Common.h>
24 #include <libdevcore/Exceptions.h>
25 #include <libdevcore/FixedHash.h>
26 
27 #include <memory>
28 
29 namespace dev
30 {
31 
32 class OverlayDB;
33 
34 namespace eth
35 {
36 
37 DEV_SIMPLE_EXCEPTION(InvalidAccountInTheDatabase);
38 
40 {
41 public:
42  virtual ~StateImporterFace() = default;
43 
44  virtual void importAccount(h256 const& _addressHash, u256 const& _nonce, u256 const& _balance, std::map<h256, bytes> const& _storage, h256 const& _codeHash) = 0;
45 
46  virtual h256 importCode(bytesConstRef _code) = 0;
47 
48  virtual void commitStateDatabase() = 0;
49 
50  virtual bool isAccountImported(h256 const& _addressHash) const = 0;
51 
52  virtual h256 stateRoot() const = 0;
53 
54  virtual std::string lookupCode(h256 const& _hash) const = 0;
55 };
56 
57 std::unique_ptr<StateImporterFace> createStateImporter(OverlayDB& _stateDb);
58 
59 }
60 }
dev::vector_ref< byte const >
dev::eth::StateImporterFace::importAccount
virtual void importAccount(h256 const &_addressHash, u256 const &_nonce, u256 const &_balance, std::map< h256, bytes > const &_storage, h256 const &_codeHash)=0
dev::eth::StateImporterFace::lookupCode
virtual std::string lookupCode(h256 const &_hash) const =0
FixedHash.h
dev::FixedHash< 32 >
dev::eth::StateImporterFace::commitStateDatabase
virtual void commitStateDatabase()=0
dev::eth::StateImporterFace::importCode
virtual h256 importCode(bytesConstRef _code)=0
Common.h
dev::eth::StateImporterFace::isAccountImported
virtual bool isAccountImported(h256 const &_addressHash) const =0
Exceptions.h
dev::OverlayDB
Definition: OverlayDB.h:34
dev::u256
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
Definition: Common.h:121
dev::eth::DEV_SIMPLE_EXCEPTION
DEV_SIMPLE_EXCEPTION(NoHashRecorded)
dev
Definition: Address.cpp:21
dev::eth::StateImporterFace::stateRoot
virtual h256 stateRoot() const =0
dev::eth::createStateImporter
std::unique_ptr< StateImporterFace > createStateImporter(OverlayDB &_stateDb)
Definition: StateImporter.cpp:93
dev::eth::StateImporterFace
Definition: StateImporter.h:40
dev::eth::StateImporterFace::~StateImporterFace
virtual ~StateImporterFace()=default