Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AsyncGrpcCall.hpp
1#pragma once
2
3#include "etl/InitialLoadObserverInterface.hpp"
4#include "util/log/Logger.hpp"
5
6#include <grpcpp/client_context.h>
7#include <grpcpp/support/status.h>
8#include <xrpl/basics/base_uint.h>
9#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger_data.pb.h>
10#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15#include <string>
16#include <vector>
17
18namespace etl::impl {
19
20class AsyncGrpcCall {
21public:
22 enum class CallStatus { More, Done, Errored };
23 using RequestType = org::xrpl::rpc::v1::GetLedgerDataRequest;
24 using ResponseType = org::xrpl::rpc::v1::GetLedgerDataResponse;
25 using StubType = org::xrpl::rpc::v1::XRPLedgerAPIService::Stub;
26
27private:
28 util::Logger log_{"ETL"};
29
30 std::unique_ptr<ResponseType> cur_;
31 std::unique_ptr<ResponseType> next_;
32
33 RequestType request_;
34 std::unique_ptr<grpc::ClientContext> context_;
35
36 grpc::Status status_;
37 unsigned char nextPrefix_;
38
39 std::string lastKey_;
40 std::optional<std::string> predecessorKey_;
41
42public:
43 AsyncGrpcCall(
44 uint32_t seq,
45 ripple::uint256 const& marker,
46 std::optional<ripple::uint256> const& nextMarker
47 );
48
49 static std::vector<AsyncGrpcCall>
50 makeAsyncCalls(uint32_t const sequence, uint32_t const numMarkers);
51
52 CallStatus
53 process(
54 std::unique_ptr<StubType>& stub,
55 grpc::CompletionQueue& cq,
57 bool abort
58 );
59
60 void
61 call(
62 std::unique_ptr<org::xrpl::rpc::v1::XRPLedgerAPIService::Stub>& stub,
63 grpc::CompletionQueue& cq
64 );
65
66 std::string
67 getMarkerPrefix();
68
69 std::string
70 getLastKey();
71};
72
73} // namespace etl::impl
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:78
The interface for observing the initial ledger load.
Definition InitialLoadObserverInterface.hpp:17