Ethereum  PoC-8
The C++ Implementation of Ethereum
SnapshotStorage.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 */
17 
18 #pragma once
19 
20 #include <libdevcore/Common.h>
21 #include <libdevcore/Exceptions.h>
22 #include <libdevcore/FixedHash.h>
23 
24 #include <boost/filesystem.hpp>
25 
26 #include <memory>
27 
28 namespace dev
29 {
30 
31 namespace eth
32 {
33 
34 DEV_SIMPLE_EXCEPTION(FailedToReadSnapshotManifestFile);
35 DEV_SIMPLE_EXCEPTION(FailedToReadChunkFile);
36 DEV_SIMPLE_EXCEPTION(ChunkIsTooBig);
37 DEV_SIMPLE_EXCEPTION(ChunkDataCorrupted);
38 DEV_SIMPLE_EXCEPTION(FailedToGetUncompressedLength);
39 DEV_SIMPLE_EXCEPTION(FailedToUncompressedSnapshotChunk);
40 
42 {
43 public:
44  virtual ~SnapshotStorageFace() = default;
45 
46  virtual bytes readManifest() const = 0;
47 
48  virtual std::string readCompressedChunk(h256 const& _chunkHash) const = 0;
49 
50  virtual std::string readChunk(h256 const& _chunkHash) const = 0;
51 
52  virtual void copyTo(boost::filesystem::path const& _path) const = 0;
53 };
54 
55 
56 std::unique_ptr<SnapshotStorageFace> createSnapshotStorage(
57  boost::filesystem::path const& _snapshotDirPath);
58 
59 boost::filesystem::path importedSnapshotPath(
60  boost::filesystem::path const& _dataDir, h256 const& _genesisHash);
61 }
62 }
dev::eth::SnapshotStorageFace::readCompressedChunk
virtual std::string readCompressedChunk(h256 const &_chunkHash) const =0
dev::eth::SnapshotStorageFace::copyTo
virtual void copyTo(boost::filesystem::path const &_path) const =0
dev::eth::SnapshotStorageFace::~SnapshotStorageFace
virtual ~SnapshotStorageFace()=default
FixedHash.h
dev::eth::SnapshotStorageFace
Definition: SnapshotStorage.h:42
dev::FixedHash< 32 >
dev::eth::SnapshotStorageFace::readChunk
virtual std::string readChunk(h256 const &_chunkHash) const =0
Common.h
dev::bytes
std::vector< byte > bytes
Definition: Common.h:72
dev::eth::createSnapshotStorage
std::unique_ptr< SnapshotStorageFace > createSnapshotStorage(fs::path const &_snapshotDirPath)
Definition: SnapshotStorage.cpp:98
Exceptions.h
dev::eth::SnapshotStorageFace::readManifest
virtual bytes readManifest() const =0
dev::eth::DEV_SIMPLE_EXCEPTION
DEV_SIMPLE_EXCEPTION(NoHashRecorded)
dev
Definition: Address.cpp:21
dev::eth::importedSnapshotPath
fs::path importedSnapshotPath(fs::path const &_dataDir, h256 const &_genesisHash)
Definition: SnapshotStorage.cpp:103