#ifndef RIPPLE_APP_REPORTING_POSTGRESBACKEND_H_INCLUDED #define RIPPLE_APP_REPORTING_POSTGRESBACKEND_H_INCLUDED #include #include namespace Backend { class PostgresBackend : public BackendInterface { private: mutable size_t numRowsInObjectsBuffer_ = 0; mutable std::stringstream objectsBuffer_; mutable std::stringstream transactionsBuffer_; mutable std::stringstream booksBuffer_; mutable std::stringstream accountTxBuffer_; std::shared_ptr pgPool_; mutable PgQuery writeConnection_; mutable bool abortWrite_ = false; public: PostgresBackend(boost::json::object const& config); std::optional fetchLatestLedgerSequence() const override; std::optional fetchLedgerBySequence(uint32_t sequence) const override; std::optional fetchLedgerRange() const override; std::optional fetchLedgerObject(ripple::uint256 const& key, uint32_t sequence) const override; // returns a transaction, metadata pair std::optional fetchTransaction(ripple::uint256 const& hash) const override; std::vector fetchAllTransactionsInLedger(uint32_t ledgerSequence) const override; std::vector fetchAllTransactionHashesInLedger(uint32_t ledgerSequence) const override; LedgerPage fetchLedgerPage( std::optional const& cursor, std::uint32_t ledgerSequence, std::uint32_t limit) const override; std::pair, std::optional> fetchBookOffers( ripple::uint256 const& book, uint32_t ledgerSequence, std::uint32_t limit, std::optional const& cursor) const override; std::vector fetchTransactions( std::vector const& hashes) const override; std::vector fetchLedgerObjects( std::vector const& keys, uint32_t sequence) const override; std::pair< std::vector, std::optional> fetchAccountTransactions( ripple::AccountID const& account, std::uint32_t limit, std::optional const& cursor) const override; void writeLedger( ripple::LedgerInfo const& ledgerInfo, std::string&& ledgerHeader, bool isFirst) const override; void writeLedgerObject( std::string&& key, uint32_t seq, std::string&& blob, bool isCreated, bool isDeleted, std::optional&& book) const override; void writeTransaction( std::string&& hash, uint32_t seq, std::string&& transaction, std::string&& metadata) const override; void writeAccountTransactions( std::vector&& data) const override; void open() override; void close() override; void startWrites() const override; bool finishWrites() const override; bool doOnlineDelete(uint32_t minLedgerToKeep) const override; }; } // namespace Backend #endif