//------------------------------------------------------------------------------ /* This file is part of clio: https://github.com/XRPLF/clio Copyright (c) 2024, the clio developers. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #pragma once #include "etl/ExtractorInterface.hpp" #include "etl/LedgerFetcherInterface.hpp" #include "etl/Models.hpp" #include "etl/impl/LedgerFetcher.hpp" #include "util/log/Logger.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace etl::impl { using PBObjType = org::xrpl::rpc::v1::RawLedgerObject; using PBModType = PBObjType::ModificationType; using PBTxType = org::xrpl::rpc::v1::TransactionAndMetadata; using PBTxListType = google::protobuf::RepeatedPtrField; using PBObjListType = google::protobuf::RepeatedPtrField; using PBBookSuccessorType = org::xrpl::rpc::v1::BookSuccessor; using PBLedgerResponseType = org::xrpl::rpc::v1::GetLedgerResponse; [[nodiscard]] model::Object::ModType extractModType(PBModType type); [[nodiscard]] model::Transaction extractTx(PBTxType tx, uint32_t seq); [[nodiscard]] std::vector extractTxs(PBTxListType transactions, uint32_t seq); [[nodiscard]] model::Object extractObj(PBObjType obj); [[nodiscard]] std::vector extractObjs(PBObjListType objects); [[nodiscard]] model::BookSuccessor extractSuccessor(PBBookSuccessorType successor); [[nodiscard]] std::optional> maybeExtractSuccessors(PBLedgerResponseType const& data); // fetches the data in gRPC and transforms to local representation class Extractor : public ExtractorInterface { std::shared_ptr fetcher_; util::Logger log_{"ETL"}; private: [[nodiscard]] static auto unpack(); public: Extractor(std::shared_ptr fetcher) : fetcher_(std::move(fetcher)) { } Extractor(Extractor const&) = delete; Extractor(Extractor&&) = delete; Extractor& operator=(Extractor const&) = delete; Extractor& operator=(Extractor&&) = delete; [[nodiscard]] std::optional extractLedgerWithDiff(uint32_t seq) override; [[nodiscard]] std::optional extractLedgerOnly(uint32_t seq) override; }; } // namespace etl::impl