Skip to content

Commit

Permalink
Fix network identity subsystem problems and make it private
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph M. Wintersteiger committed Mar 25, 2022
1 parent 932fdff commit 2ed4810
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 30 deletions.
13 changes: 0 additions & 13 deletions include/ccf/node_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "ccf/historical_queries_interface.h"
#include "ccf/indexing/indexer_interface.h"
#include "ccf/network_identity_interface.h"
#include "ccf/node_subsystem_interface.h"

namespace ccfapp
Expand Down Expand Up @@ -89,17 +88,5 @@ namespace ccfapp
}
return *indexer;
}

ccf::NetworkIdentitySubsystemInterface& get_network_identity()
{
auto identity_subsystem =
get_subsystem<ccf::NetworkIdentitySubsystemInterface>();
if (identity_subsystem == nullptr)
{
throw std::logic_error(
"Calling get_network_identity before subsystem is installed");
}
return *identity_subsystem;
}
};
}
1 change: 0 additions & 1 deletion samples/apps/logging/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "ccf/http_query.h"
#include "ccf/indexing/strategies/seqnos_by_key_bucketed.h"
#include "ccf/json_handler.h"
#include "ccf/network_identity_interface.h"
#include "ccf/version.h"
#include "kv/store.h"

Expand Down
1 change: 0 additions & 1 deletion src/apps/js_generic/js_generic_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "ccf/crypto/key_wrap.h"
#include "ccf/crypto/rsa_key_pair.h"
#include "ccf/historical_queries_adapter.h"
#include "ccf/network_identity_interface.h"
#include "ccf/version.h"
#include "js/wrap.h"
#include "kv/untyped_map.h"
Expand Down
30 changes: 16 additions & 14 deletions src/node/historical_queries_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the Apache 2.0 License.

#include "ccf/historical_queries_adapter.h"

#include "ccf/network_identity_interface.h"
#include "ccf/rpc_context.h"
#include "ccf/service/tables/service.h"
#include "kv/kv_types.h"
Expand Down Expand Up @@ -215,8 +213,8 @@ namespace ccf::historical
if (!hservice_info->previous_service_identity_version)
{
throw std::runtime_error(
"The requested receipt cannot be found because it is in a pre-2.x "
"part of the ledger");
"The service identity that signed the receipt cannot be found "
"because it is in a pre-2.x part of the ledger.");
}
i = hservice_info->previous_service_identity_version.value_or(i - 1);
LOG_TRACE_FMT("historical service identity search at: {}", i);
Expand All @@ -242,9 +240,16 @@ namespace ccf::historical
auto& ctx,
ccf::historical::StatePtr& state,
AbstractStateCache& state_cache,
NetworkIdentitySubsystemInterface& network_identity_subsystem)
std::shared_ptr<NetworkIdentitySubsystem> network_identity_subsystem)
{
const auto& network_identity = network_identity_subsystem.get();
if (!network_identity_subsystem)
{
throw std::runtime_error(
"The service identity endorsement for this receipt cannot be created "
"because the current network identity is not available.");
}

const auto& network_identity = network_identity_subsystem->get();

if (state && state->receipt && state->receipt->node_cert)
{
Expand Down Expand Up @@ -301,12 +306,10 @@ namespace ccf::historical
const TxIDExtractor& extractor)
{
auto& state_cache = node_context.get_historical_state();
std::shared_ptr<NetworkIdentitySubsystemInterface>
network_identity_subsystem =
node_context.get_subsystem<NetworkIdentitySubsystemInterface>(
"NetworkIdentity");
std::shared_ptr<NetworkIdentitySubsystem> network_identity_subsystem =
node_context.get_subsystem<NetworkIdentitySubsystem>();

return [f, &state_cache, &network_identity_subsystem, available, extractor](
return [f, &state_cache, network_identity_subsystem, available, extractor](
endpoints::EndpointContext& args) {
// Extract the requested transaction ID
ccf::TxID target_tx_id;
Expand Down Expand Up @@ -374,9 +377,8 @@ namespace ccf::historical
state_cache.get_state_at(historic_request_handle, target_tx_id.seqno);
if (
historical_state == nullptr ||
(network_identity_subsystem &&
!get_service_endorsements(
args, historical_state, state_cache, *network_identity_subsystem)))
(!get_service_endorsements(
args, historical_state, state_cache, network_identity_subsystem)))
{
args.rpc_ctx->set_response_status(HTTP_STATUS_ACCEPTED);
constexpr size_t retry_after_seconds = 3;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/node/rpc/network_identity_subsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the Apache 2.0 License.
#pragma once

#include "ccf/network_identity_interface.h"
#include "node/identity.h"
#include "node/rpc/network_identity_interface.h"
#include "node/rpc/node_interface.h"

namespace ccf
Expand Down

0 comments on commit 2ed4810

Please sign in to comment.