From 2ea38678f24697818fbe16f586430a8f67a91854 Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Tue, 19 Dec 2023 10:20:49 +0000 Subject: [PATCH] Remove ccf::historical::adapter_v2 (#5873) --- CHANGELOG.md | 1 + include/ccf/historical_queries_adapter.h | 17 ----- src/node/historical_queries_adapter.cpp | 91 ------------------------ 3 files changed, 1 insertion(+), 108 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10bd1e1e50e2..2953acf6108e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed +- `ccf::historical::adapter_v2` is removed, replaced by `ccf::historical::adapter_v3` first introduced in 2.0.0. - `ccf::EnclaveAttestationProvider` has been removed. It is replaced by `ccf::AttestationProvider` ## [5.0.0-dev10] diff --git a/include/ccf/historical_queries_adapter.h b/include/ccf/historical_queries_adapter.h index 0a23633d72b7..837c9d3eed1f 100644 --- a/include/ccf/historical_queries_adapter.h +++ b/include/ccf/historical_queries_adapter.h @@ -73,21 +73,4 @@ namespace ccf::historical ccfapp::AbstractNodeContext& node_context, const CheckHistoricalTxStatus& available, const TxIDExtractor& extractor = txid_from_header); - - /// @cond - // Doxygen cannot parse these declarations; some combination of a macro, - // attribute syntax, and namespaced types results in the following warning - // (treated as error): - // Found ';' while parsing initializer list! (doxygen could be confused by a - // macro call without semicolon) - // Use label-less cond to unconditionally exclude this block from parsing - // until the declarations are removed are removed. - CCF_DEPRECATED( - "Will be removed in 3.0, switch to ccf::historical::adapter_v3") - ccf::endpoints::EndpointFunction adapter_v2( - const HandleHistoricalQuery& f, - ccfapp::AbstractNodeContext& node_context, - const CheckHistoricalTxStatus& available, - const TxIDExtractor& extractor = txid_from_header); - /// @endcond } \ No newline at end of file diff --git a/src/node/historical_queries_adapter.cpp b/src/node/historical_queries_adapter.cpp index 83a21bbe8469..1d95056c6f1a 100644 --- a/src/node/historical_queries_adapter.cpp +++ b/src/node/historical_queries_adapter.cpp @@ -374,95 +374,4 @@ namespace ccf::historical ccf::endpoints::EndpointFunction, ccf::endpoints::EndpointContext>(f, node_context, available, extractor); } - - ccf::endpoints::EndpointFunction adapter_v2( - const HandleHistoricalQuery& f, - AbstractStateCache& state_cache, - const CheckHistoricalTxStatus& available, - const TxIDExtractor& extractor) - { - return [f, &state_cache, available, extractor]( - endpoints::EndpointContext& args) { - // Extract the requested transaction ID - ccf::TxID target_tx_id; - { - const auto tx_id_opt = extractor(args); - if (tx_id_opt.has_value()) - { - target_tx_id = tx_id_opt.value(); - } - else - { - return; - } - } - - // Check that the requested transaction ID is available - { - auto error_reason = fmt::format( - "Transaction {} is not available.", target_tx_id.to_str()); - auto is_available = - available(target_tx_id.view, target_tx_id.seqno, error_reason); - switch (is_available) - { - case HistoricalTxStatus::Error: - { - args.rpc_ctx->set_error( - HTTP_STATUS_INTERNAL_SERVER_ERROR, - ccf::errors::TransactionPendingOrUnknown, - std::move(error_reason)); - return; - } - case HistoricalTxStatus::PendingOrUnknown: - { - // Set header No-Cache - args.rpc_ctx->set_response_header( - http::headers::CACHE_CONTROL, "no-cache"); - args.rpc_ctx->set_error( - HTTP_STATUS_NOT_FOUND, - ccf::errors::TransactionPendingOrUnknown, - std::move(error_reason)); - return; - } - case HistoricalTxStatus::Invalid: - { - args.rpc_ctx->set_error( - HTTP_STATUS_NOT_FOUND, - ccf::errors::TransactionInvalid, - std::move(error_reason)); - return; - } - case HistoricalTxStatus::Valid: - { - } - } - } - - // We need a handle to determine whether this request is the 'same' as a - // previous one. For simplicity we use target_tx_id.seqno. This means we - // keep a lot of state around for old requests! It should be cleaned up - // manually - const auto historic_request_handle = target_tx_id.seqno; - - // Get a state at the target version from the cache, if it is present - auto historical_state = - state_cache.get_state_at(historic_request_handle, target_tx_id.seqno); - if (historical_state == nullptr) - { - args.rpc_ctx->set_response_status(HTTP_STATUS_ACCEPTED); - constexpr size_t retry_after_seconds = 3; - args.rpc_ctx->set_response_header( - http::headers::RETRY_AFTER, retry_after_seconds); - args.rpc_ctx->set_response_header( - http::headers::CONTENT_TYPE, http::headervalues::contenttype::TEXT); - args.rpc_ctx->set_response_body(fmt::format( - "Historical transaction {} is not currently available.", - target_tx_id.to_str())); - return; - } - - // Call the provided handler - f(args, historical_state); - }; - } } \ No newline at end of file