rippled
DatabaseDownloader.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2020 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_NET_DATABASEDOWNLOADER_H
21 #define RIPPLE_NET_DATABASEDOWNLOADER_H
22 
23 #include <ripple/net/DatabaseBody.h>
24 #include <ripple/net/HTTPDownloader.h>
25 
26 namespace ripple {
27 
29 {
30 public:
31  virtual ~DatabaseDownloader() = default;
32 
33 private:
35  boost::asio::io_service& io_service,
36  Config const& config,
37  beast::Journal j);
38 
39  static const std::uint8_t MAX_PATH_LEN =
41 
43  getParser(
44  boost::filesystem::path dstPath,
45  std::function<void(boost::filesystem::path)> complete,
46  boost::system::error_code& ec) override;
47 
48  bool
49  checkPath(boost::filesystem::path const& dstPath) override;
50 
51  void
53 
55  size(std::shared_ptr<parser> p) override;
56 
57  Config const& config_;
58  boost::asio::io_service& io_service_;
59 
62  boost::asio::io_service& io_service,
63  Config const& config,
64  beast::Journal j);
65 };
66 
67 // DatabaseDownloader must be a shared_ptr because it uses shared_from_this
70  boost::asio::io_service& io_service,
71  Config const& config,
72  beast::Journal j);
73 
74 } // namespace ripple
75 
76 #endif // RIPPLE_NET_DATABASEDOWNLOADER_H
std::shared_ptr
STL class.
ripple::DatabaseDownloader::checkPath
bool checkPath(boost::filesystem::path const &dstPath) override
Definition: DatabaseDownloader.cpp:63
std::function
ripple::DatabaseDownloader::closeBody
void closeBody(std::shared_ptr< parser > p) override
Definition: DatabaseDownloader.cpp:69
ripple::DatabaseDownloader::~DatabaseDownloader
virtual ~DatabaseDownloader()=default
ripple::Config
Definition: Config.h:89
ripple::DatabaseDownloader::make_DatabaseDownloader
friend std::shared_ptr< DatabaseDownloader > make_DatabaseDownloader(boost::asio::io_service &io_service, Config const &config, beast::Journal j)
Definition: DatabaseDownloader.cpp:25
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint8_t
ripple::DatabaseDownloader::config_
Config const & config_
Definition: DatabaseDownloader.h:57
ripple::DatabaseDownloader::io_service_
boost::asio::io_service & io_service_
Definition: DatabaseDownloader.h:58
ripple::DatabaseDownloader::DatabaseDownloader
DatabaseDownloader(boost::asio::io_service &io_service, Config const &config, beast::Journal j)
Definition: DatabaseDownloader.cpp:34
ripple::DatabaseDownloader::MAX_PATH_LEN
static const std::uint8_t MAX_PATH_LEN
Definition: DatabaseDownloader.h:39
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::DatabaseDownloader::getParser
std::shared_ptr< parser > getParser(boost::filesystem::path dstPath, std::function< void(boost::filesystem::path)> complete, boost::system::error_code &ec) override
Definition: DatabaseDownloader.cpp:45
ripple::DatabaseDownloader::size
std::uint64_t size(std::shared_ptr< parser > p) override
Definition: DatabaseDownloader.cpp:81
ripple::DatabaseDownloader
Definition: DatabaseDownloader.h:28
std::numeric_limits::max
T max(T... args)
ripple::HTTPDownloader
Provides an asynchronous HTTP[S] file downloader.
Definition: HTTPDownloader.h:44
ripple::make_DatabaseDownloader
std::shared_ptr< DatabaseDownloader > make_DatabaseDownloader(boost::asio::io_service &io_service, Config const &config, beast::Journal j)
Definition: DatabaseDownloader.cpp:25