Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2016 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of the nTorrent codebase. |
| 6 | * |
| 7 | * nTorrent is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * nTorrent is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with nTorrent, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS for complete list of nTorrent authors and contributors. |
| 20 | */ |
| 21 | #ifndef INCLUDED_TORRENT_FILE_MANAGER_H |
| 22 | #define INCLUDED_TORRENT_FILE_MANAGER_H |
| 23 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 24 | #include "file-manifest.hpp" |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 25 | #include "torrent-file.hpp" |
spirosmastorakis | 4ff8c87 | 2016-04-14 09:51:38 -0700 | [diff] [blame] | 26 | #include "update-handler.hpp" |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 27 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 28 | #include <ndn-cxx/data.hpp> |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 29 | #include <ndn-cxx/face.hpp> |
| 30 | #include <ndn-cxx/interest.hpp> |
| 31 | #include <ndn-cxx/link.hpp> |
| 32 | #include <ndn-cxx/name.hpp> |
| 33 | #include <ndn-cxx/security/key-chain.hpp> |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 34 | |
| 35 | #include <boost/filesystem/fstream.hpp> |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 36 | |
| 37 | #include <functional> |
| 38 | #include <memory> |
| 39 | #include <string> |
| 40 | #include <unordered_map> |
| 41 | #include <vector> |
| 42 | |
| 43 | namespace fs = boost::filesystem; |
| 44 | |
| 45 | namespace ndn { |
| 46 | namespace ntorrent { |
| 47 | |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 48 | class TorrentManager : noncopyable { |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 49 | /** |
| 50 | * \class TorrentManager |
| 51 | * |
| 52 | * \brief A class to manage the interaction with the system in seeding/leaching a torrent |
| 53 | */ |
| 54 | public: |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 55 | typedef std::function<void(const ndn::Name&)> DataReceivedCallback; |
| 56 | typedef std::function<void(const std::vector<ndn::Name>&)> ManifestReceivedCallback; |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 57 | typedef std::function<void(const std::vector<ndn::Name>&)> TorrentFileReceivedCallback; |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 58 | typedef std::function<void(const ndn::Name&, const std::string&)> FailedCallback; |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 59 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 60 | /* |
| 61 | * \brief Create a new Torrent manager with the specified parameters. |
| 62 | * @param torrentFileName The full name of the initial segment of the torrent file |
| 63 | * @param dataPath The path to the location on disk to use for the torrent data |
| 64 | * @param face Optional face object to be used for data retrieval |
| 65 | * |
| 66 | * The behavior is undefined unless Initialize() is called before calling any other method on a |
| 67 | * TorrentManger object. |
| 68 | */ |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 69 | TorrentManager(const ndn::Name& torrentFileName, |
| 70 | const std::string& dataPath, |
| 71 | std::shared_ptr<Face> face = nullptr); |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 72 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 73 | /* |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 74 | * @brief Initialize the state of this object. |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 75 | * |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 76 | * Read and validate from disk all torrent file segments, file manifests, and data packets for |
| 77 | * the torrent file managed by this object initializing all state in this manager respectively. |
| 78 | * Also seeds all validated data. |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 79 | */ |
| 80 | void |
| 81 | Initialize(); |
| 82 | |
| 83 | /* |
| 84 | * @brief Download the torrent file |
| 85 | * @param path The path to write the downloaded segments |
| 86 | * @return A vector of the file manifest names contained in the torrent file |
| 87 | * |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 88 | */ |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 89 | std::vector<Name> |
| 90 | downloadTorrentFile(const std::string& path); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 91 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 92 | /* |
| 93 | * @brief Download the torrent file |
| 94 | * @param path The path to write the downloaded segments |
| 95 | * @param onSuccess Callback to be called if we successfully download all the |
| 96 | * segments of the torrent file. It passes the name of the file manifest |
| 97 | * to be downloaded to the callback |
| 98 | * @param onFailed Callaback to be called if we fail to download a segment of |
| 99 | * the torrent file. It passes the name of the torrent file segment that |
| 100 | * failed to download and a failure reason to the callback |
| 101 | * |
| 102 | * This method provides non-blocking downloading of all the torrent file segments |
| 103 | * |
| 104 | */ |
| 105 | void |
| 106 | downloadTorrentFile(const std::string& path, |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 107 | TorrentFileReceivedCallback onSuccess, |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 108 | FailedCallback onFailed); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 109 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 110 | /* |
| 111 | * @brief Download a file manifest |
| 112 | * @param manifestName The name of the manifest file to be downloaded |
| 113 | * @param path The path to write the downloaded segments |
| 114 | * @param onSuccess Callback to be called if we successfully download all the |
| 115 | * segments of the file manifest. It passes the names of the data packets |
| 116 | * to be downloaded to the callback |
| 117 | * @param onFailed Callaback to be called if we fail to download a segment of |
| 118 | * the file manifest. It passes the name of the data packet that failed |
| 119 | * to download and a failure reason |
| 120 | * |
| 121 | * This method provides non-blocking downloading of all the file manifest segments |
| 122 | * |
| 123 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 124 | void |
| 125 | download_file_manifest(const Name& manifestName, |
| 126 | const std::string& path, |
| 127 | ManifestReceivedCallback onSuccess, |
| 128 | FailedCallback onFailed); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 129 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 130 | /* |
| 131 | * @brief Download a data packet |
| 132 | * @param packetName The name of the data packet to be downloaded |
| 133 | * @param onSuccess Callback to be called if we successfully download the data packet. |
| 134 | * It passes the name of the data packet to the callback |
| 135 | * @param onFailed Callaback to be called if we fail to download the requested data packet |
| 136 | * It passes the name of the data packet to the callback and a failure reason |
| 137 | * |
| 138 | * This method writes the downloaded data packet to m_dataPath on disk |
| 139 | * |
| 140 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 141 | void |
| 142 | download_data_packet(const Name& packetName, |
| 143 | DataReceivedCallback onSuccess, |
| 144 | FailedCallback onFailed); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 145 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 146 | // Seed the specified 'data' to the network. |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 147 | void |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 148 | seed(const Data& data); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 149 | |
Mickey Sweatt | b7ee19c | 2016-04-21 12:18:15 -0700 | [diff] [blame] | 150 | /** |
| 151 | * @brief Process any data to receive or call timeout callbacks and update prefix list (if needed) |
| 152 | * By default only process pending events and return immediately, optionally specify a timeout. |
| 153 | */ |
| 154 | void |
| 155 | processEvents(const time::milliseconds& timeout = time::milliseconds(-1)); |
| 156 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 157 | protected: |
Mickey Sweatt | b7ee19c | 2016-04-21 12:18:15 -0700 | [diff] [blame] | 158 | /** |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 159 | * \brief Write @p packet composed of torrent date to disk. |
| 160 | * @param packet The data packet to be written to the disk |
| 161 | * Write the Data packet to disk, return 'true' if data successfully written to disk 'false' |
| 162 | * otherwise. Behavior is undefined unless the corresponding file manifest has already been |
| 163 | * downloaded. |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 164 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 165 | bool |
| 166 | writeData(const Data& packet); |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 167 | |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 168 | /* |
| 169 | * \brief Write the @p segment torrent segment to disk at the specified path. |
| 170 | * @param segment The torrent file segment to be written to disk |
| 171 | * @param path The path at which to write the torrent file segment |
| 172 | * Write the segment to disk, return 'true' if data successfully written to disk 'false' |
| 173 | * otherwise. Behavior is undefined unless @segment is a correct segment for the torrent file of |
| 174 | * this manager and @p path is the directory used for all segments of this torrent file. |
| 175 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 176 | bool |
| 177 | writeTorrentSegment(const TorrentFile& segment, const std::string& path); |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 178 | |
Mickey Sweatt | 599bfef | 2016-04-05 19:11:20 -0700 | [diff] [blame] | 179 | /* |
| 180 | * \brief Write the @p manifest file manifest to disk at the specified @p path. |
| 181 | * @param manifest The file manifest to be written to disk |
| 182 | * @param path The path at which to write the file manifest |
| 183 | * Write the file manifest to disk, return 'true' if data successfully written to disk 'false' |
| 184 | * otherwise. Behavior is undefined unless @manifest is a correct file manifest for a file in the |
| 185 | * torrent file of this manager and @p path is the directory used for all file manifests of this |
| 186 | * torrent file. |
| 187 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 188 | bool |
| 189 | writeFileManifest(const FileManifest& manifest, const std::string& path); |
Mickey Sweatt | afda1f1 | 2016-04-04 17:15:11 -0700 | [diff] [blame] | 190 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 191 | /* |
| 192 | * \brief Download the segments of the torrent file |
| 193 | * @param name The name of the torrent file to be downloaded |
| 194 | * @param path The path to write the torrent file on disk |
| 195 | * @param manifestNames A vector containing the name of the manifests in the torrent file. |
| 196 | * This parameter will be updated every time we receive a torrent |
| 197 | * file segment |
| 198 | * @param async Blocking (sync) or non-blocking (async) operation |
| 199 | * @param onSuccess Optional callback to be called when all the segments of the torrent file |
| 200 | * have been downloaded. The default value is an empty callack. A callback |
| 201 | * should be specified when async is false |
| 202 | * @param onFailed Optional callback to be called when we fail to download a segment of the |
| 203 | * torrent file. The default value is an empty callack. A callback should be |
| 204 | * specified when async is false |
| 205 | * |
| 206 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 207 | void |
| 208 | downloadTorrentFileSegment(const ndn::Name& name, |
| 209 | const std::string& path, |
| 210 | std::shared_ptr<std::vector<Name>> manifestNames, |
| 211 | bool async, |
| 212 | TorrentFileReceivedCallback onSuccess, |
| 213 | FailedCallback onFailed); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 214 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 215 | /* |
| 216 | * \brief Download the segments of a file manifest |
| 217 | * @param manifestName The name of the file manifest to be downloaded |
| 218 | * @param path The path to write the file manifest on disk |
| 219 | * @param packetNames A vector containing the name of the data packets in the file manifest |
| 220 | * @param onSuccess Callback to be called when all the segments of the file manifest have been |
| 221 | * downloaded |
| 222 | * @param onFailed Callback to be called when we fail to download a file manifest segment |
| 223 | * |
| 224 | */ |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 225 | void |
| 226 | downloadFileManifestSegment(const Name& manifestName, |
| 227 | const std::string& path, |
| 228 | std::shared_ptr<std::vector<Name>> packetNames, |
| 229 | ManifestReceivedCallback onSuccess, |
| 230 | FailedCallback onFailed); |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 231 | |
| 232 | enum { |
| 233 | // Number of times to retry if a routable prefix fails to retrieve data |
| 234 | MAX_NUM_OF_RETRIES = 5, |
| 235 | // Number of Interests to be sent before sorting the stats table |
| 236 | SORTING_INTERVAL = 100 |
| 237 | }; |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 238 | |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 239 | void onDataReceived(const Data& data); |
| 240 | |
| 241 | void |
| 242 | onInterestReceived(const InterestFilter& filter, const Interest& interest); |
| 243 | |
| 244 | void |
| 245 | onRegisterFailed(const Name& prefix, const std::string& reason); |
| 246 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 247 | // A map from each fileManifest to corresponding file stream on disk and a bitmap of which Data |
| 248 | // packets this manager currently has |
| 249 | mutable std::unordered_map<Name, |
| 250 | std::pair<std::shared_ptr<fs::fstream>, |
| 251 | std::vector<bool>>> m_fileStates; |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 252 | // A map for each initial manifest to the size for the sub-manifest |
| 253 | std::unordered_map<std::string, size_t> m_subManifestSizes; |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 254 | // The segments of the TorrentFile this manager has |
| 255 | std::vector<TorrentFile> m_torrentSegments; |
| 256 | // The FileManifests this manager has |
| 257 | std::vector<FileManifest> m_fileManifests; |
| 258 | // The name of the initial segment of the torrent file for this manager |
| 259 | Name m_torrentFileName; |
| 260 | // The path to the location on disk of the Data packet for this manager |
| 261 | std::string m_dataPath; |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 262 | |
spirosmastorakis | 50642f8 | 2016-04-08 12:11:18 -0700 | [diff] [blame] | 263 | protected: |
| 264 | /* |
| 265 | * \brief Find the torrent file segment that we should download |
| 266 | * (either we have nothing or we have them all) |
| 267 | * @return A shared_ptr to the name of the segment to download or |
| 268 | * nullptr if we have all the segments |
| 269 | * |
| 270 | */ |
| 271 | shared_ptr<Name> |
| 272 | findTorrentFileSegmentToDownload(); |
| 273 | |
| 274 | /* |
| 275 | * \brief Given a file manifest segment name, find the next file manifest segment |
| 276 | * that we should download |
| 277 | * @param manifestName The name of the file manifest segment that we want to download |
| 278 | * @return A shared_ptr to the name of the segment to download or |
| 279 | * nullptr if we have all the segments |
| 280 | * |
| 281 | */ |
| 282 | shared_ptr<Name> |
| 283 | findManifestSegmentToDownload(const Name& manifestName); |
| 284 | |
| 285 | /* |
| 286 | * \brief Given a data packet name, find whether we have already downloaded this packet |
| 287 | * @param dataName The name of the data packet to download |
| 288 | * @return True if we have already downloaded this packet, false otherwise |
| 289 | * |
| 290 | */ |
| 291 | bool |
| 292 | dataAlreadyDownloaded(const Name& dataName); |
| 293 | |
| 294 | /* |
| 295 | * \brief Find the segments of all the file manifests that we are missing |
| 296 | * @param manifestNames The name of the manifest file segments to download (currently missing) |
| 297 | * This parameter is used as an output vector of names |
| 298 | */ |
| 299 | void |
| 300 | findFileManifestsToDownload(std::vector<Name>& manifestNames); |
| 301 | |
| 302 | /* |
| 303 | * \brief Find the names of the data packets of a file manifest that we are currently missing |
| 304 | * @param manifestName The name of the manifest |
| 305 | * @param packetNames The name of the data packets to be downloaded |
| 306 | * (used as an output vector of names) |
| 307 | * |
| 308 | * No matter what segment of a manifest file the manifestName parameter might refer to, the |
| 309 | * missing data packets starting from the first segment of this manifest file would be returned |
| 310 | * |
| 311 | */ |
| 312 | void |
| 313 | findDataPacketsToDownload(const Name& manifestName, std::vector<Name>& packetNames); |
| 314 | |
| 315 | /* |
| 316 | * \brief Find all the data packets that we are currently missing |
| 317 | * @param packetNames The name of the data packets to be downloaded |
| 318 | * (used as an output vector of names) |
| 319 | * |
| 320 | */ |
| 321 | void |
| 322 | findAllMissingDataPackets(std::vector<Name>& packetNames); |
| 323 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 324 | private: |
| 325 | shared_ptr<Interest> |
| 326 | createInterest(Name name); |
| 327 | |
| 328 | // Stats table where routable prefixes are stored |
| 329 | StatsTable m_statsTable; |
| 330 | // Face used for network communication |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 331 | std::shared_ptr<Face> m_face; |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 332 | // Iterator to the routable prefix that we currently use |
| 333 | StatsTable::iterator m_stats_table_iter; |
| 334 | // Number of retries per routable prefix |
| 335 | uint64_t m_retries; |
| 336 | // Number of Interests sent since last sorting |
| 337 | uint64_t m_sortingCounter; |
| 338 | // Keychain instance |
spirosmastorakis | 4ff8c87 | 2016-04-14 09:51:38 -0700 | [diff] [blame] | 339 | shared_ptr<KeyChain> m_keyChain; |
| 340 | // Update Handler instance |
| 341 | shared_ptr<UpdateHandler> m_updateHandler; |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 342 | }; |
| 343 | |
| 344 | inline |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 345 | TorrentManager::TorrentManager(const ndn::Name& torrentFileName, |
| 346 | const std::string& dataPath, |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 347 | std::shared_ptr<Face> face) |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 348 | : m_fileStates() |
| 349 | , m_torrentSegments() |
| 350 | , m_fileManifests() |
| 351 | , m_torrentFileName(torrentFileName) |
| 352 | , m_dataPath(dataPath) |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 353 | , m_face(face) |
| 354 | , m_retries(0) |
| 355 | , m_sortingCounter(0) |
| 356 | , m_keyChain(new KeyChain()) |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 357 | { |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 358 | if(face == nullptr) { |
spirosmastorakis | 4ff8c87 | 2016-04-14 09:51:38 -0700 | [diff] [blame] | 359 | m_face = make_shared<Face>(); |
Mickey Sweatt | e908a5c | 2016-04-08 14:10:45 -0700 | [diff] [blame] | 360 | } |
spirosmastorakis | 4ff8c87 | 2016-04-14 09:51:38 -0700 | [diff] [blame] | 361 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 362 | // Hardcoded prefixes for now |
| 363 | // TODO(Spyros): Think of something more clever to bootstrap... |
| 364 | m_statsTable.insert("/ucla"); |
| 365 | m_statsTable.insert("/arizona"); |
| 366 | m_stats_table_iter = m_statsTable.begin(); |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 367 | } |
| 368 | |
Mickey Sweatt | b7ee19c | 2016-04-21 12:18:15 -0700 | [diff] [blame] | 369 | inline |
| 370 | void |
| 371 | TorrentManager::processEvents(const time::milliseconds& timeout) |
| 372 | { |
| 373 | m_face->processEvents(timeout); |
| 374 | } |
| 375 | |
Mickey Sweatt | 527b049 | 2016-03-02 11:07:48 -0800 | [diff] [blame] | 376 | } // end ntorrent |
| 377 | } // end ndn |
| 378 | |
spirosmastorakis | a46eee4 | 2016-04-05 14:24:45 -0700 | [diff] [blame] | 379 | #endif // INCLUDED_TORRENT_FILE_MANAGER_H |