CCF
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
ccf::BaseEndpointRegistry Class Reference

#include <base_endpoint_registry.h>

Inherits ccf::endpoints::EndpointRegistry.

Inherited by ccf::CommonEndpointRegistry, and nobuiltins::NoBuiltinsRegistry.

Public Member Functions

 BaseEndpointRegistry (const std::string &method_prefix_, ccf::AbstractNodeContext &context_)
 
ApiResult get_view_history_v1 (std::vector< ccf::TxID > &history, ccf::View since=1)
 
ApiResult get_view_history_v2 (std::vector< ccf::TxID > &history, ccf::View since, ccf::InvalidArgsReason &reason)
 
ApiResult get_status_for_txid_v1 (ccf::View view, ccf::SeqNo seqno, ccf::TxStatus &tx_status)
 
ApiResult get_last_committed_txid_v1 (ccf::View &view, ccf::SeqNo &seqno)
 
ApiResult generate_openapi_document_v1 (ccf::kv::ReadOnlyTx &tx, const std::string &title, const std::string &description, const std::string &document_version, nlohmann::json &document)
 
ApiResult get_quote_for_this_node_v1 (ccf::kv::ReadOnlyTx &tx, QuoteInfo &quote_info)
 
ApiResult get_id_for_this_node_v1 (NodeId &node_id)
 
ApiResult get_quotes_for_all_trusted_nodes_v1 (ccf::kv::ReadOnlyTx &tx, std::map< NodeId, QuoteInfo > &quotes)
 
ApiResult get_view_for_seqno_v1 (ccf::SeqNo seqno, ccf::View &view)
 
ApiResult get_user_data_v1 (ccf::kv::ReadOnlyTx &tx, const UserId &user_id, nlohmann::json &user_data)
 
ApiResult get_member_data_v1 (ccf::kv::ReadOnlyTx &tx, const MemberId &member_id, nlohmann::json &member_data)
 
ApiResult get_user_cert_v1 (ccf::kv::ReadOnlyTx &tx, const UserId &user_id, ccf::crypto::Pem &user_cert_pem)
 
ApiResult get_member_cert_v1 (ccf::kv::ReadOnlyTx &tx, const MemberId &member_id, ccf::crypto::Pem &member_cert_pem)
 
ApiResult get_untrusted_host_time_v1 (::timespec &time)
 
- Public Member Functions inherited from ccf::endpoints::EndpointRegistry
template<typename T >
bool get_path_param (const ccf::PathParams &params, const std::string &param_name, T &value, std::string &error)
 
template<>
bool get_path_param (const ccf::PathParams &params, const std::string &param_name, std::string &value, std::string &error)
 
 EndpointRegistry (const std::string &method_prefix_)
 
virtual ~EndpointRegistry ()
 
virtual Endpoint make_endpoint (const std::string &method, RESTVerb verb, const EndpointFunction &f, const AuthnPolicies &ap)
 
virtual Endpoint make_read_only_endpoint (const std::string &method, RESTVerb verb, const ReadOnlyEndpointFunction &f, const AuthnPolicies &ap)
 
virtual Endpoint make_endpoint_with_local_commit_handler (const std::string &method, RESTVerb verb, const EndpointFunction &f, const LocallyCommittedEndpointFunction &l, const AuthnPolicies &ap)
 
virtual Endpoint make_read_only_endpoint_with_local_commit_handler (const std::string &method, RESTVerb verb, const ReadOnlyEndpointFunction &f, const LocallyCommittedEndpointFunction &l, const AuthnPolicies &ap)
 
virtual Endpoint make_command_endpoint (const std::string &method, RESTVerb verb, const CommandEndpointFunction &f, const AuthnPolicies &ap)
 
void install (Endpoint &endpoint) override
 
void set_default (EndpointFunction f, const AuthnPolicies &ap)
 
virtual void build_api (nlohmann::json &document, ccf::kv::ReadOnlyTx &)
 
virtual void init_handlers ()
 
virtual EndpointDefinitionPtr find_endpoint (ccf::kv::Tx &, ccf::RpcContext &rpc_ctx)
 
virtual void execute_endpoint (EndpointDefinitionPtr e, EndpointContext &ctx)
 
virtual void execute_endpoint_locally_committed (EndpointDefinitionPtr e, CommandEndpointContext &ctx, const TxID &tx_id)
 
virtual std::set< RESTVerbget_allowed_verbs (ccf::kv::Tx &, const ccf::RpcContext &rpc_ctx)
 
virtual bool request_needs_root (const ccf::RpcContext &rpc_ctx)
 
virtual void report_ambiguous_templated_path (const std::string &path, const std::vector< EndpointDefinitionPtr > &matches)
 
virtual void tick (std::chrono::milliseconds)
 
void set_consensus (ccf::kv::Consensus *c)
 
void set_history (ccf::kv::TxHistory *h)
 
virtual void handle_event_request_completed (const ccf::endpoints::RequestCompletedEvent &event)
 
virtual void handle_event_dispatch_failed (const ccf::endpoints::DispatchFailedEvent &event)
 
virtual bool apply_uncommitted_tx_backpressure () const
 

Protected Attributes

ccf::AbstractNodeContextcontext
 
- Protected Attributes inherited from ccf::endpoints::EndpointRegistry
EndpointPtr default_endpoint
 
std::map< std::string, std::map< RESTVerb, EndpointPtr > > fully_qualified_endpoints
 
std::map< std::string, std::map< RESTVerb, std::shared_ptr< PathTemplatedEndpoint > > > templated_endpoints
 
ccf::kv::Consensusconsensus = nullptr
 
ccf::kv::TxHistoryhistory = nullptr
 

Additional Inherited Members

- Public Types inherited from ccf::endpoints::EndpointRegistry
enum  ReadWrite { Read , Write }
 
- Public Attributes inherited from ccf::endpoints::EndpointRegistry
const std::string method_prefix
 
struct ccf::endpoints::EndpointRegistry::OpenApiInfo openapi_info
 

Detailed Description

Extends the basic ccf::endpoints::EndpointRegistry with helper API methods for retrieving core CCF properties.

The API methods are versioned with a _vN suffix. App developers should use the latest version which provides the values they need. Note that the N in these versions is specific to each method name, and is not related to a specific CCF release version. These APIs will be stable and supported for several CCF releases.

The methods have a consistent calling pattern, taking their arguments first and setting results to the later out-parameters, passed by reference. All return an ApiResult, with value OK if the call succeeded.

Constructor & Destructor Documentation

◆ BaseEndpointRegistry()

ccf::BaseEndpointRegistry::BaseEndpointRegistry ( const std::string &  method_prefix_,
ccf::AbstractNodeContext context_ 
)

Member Function Documentation

◆ generate_openapi_document_v1()

ApiResult ccf::BaseEndpointRegistry::generate_openapi_document_v1 ( ccf::kv::ReadOnlyTx tx,
const std::string &  title,
const std::string &  description,
const std::string &  document_version,
nlohmann::json &  document 
)

Generate an OpenAPI document describing the currently installed endpoints.

The document is compatible with OpenAPI version 3.0.0 - the _v1 suffix describes the version of this API, not the returned document format. Similarly, the document_version argument should be used to version the returned document itself as the set of endpoints or their APIs change, it does not affect the OpenAPI version of the format of the document.

◆ get_id_for_this_node_v1()

ApiResult ccf::BaseEndpointRegistry::get_id_for_this_node_v1 ( NodeId node_id)

Get the id of the currently executing node.

◆ get_last_committed_txid_v1()

ApiResult ccf::BaseEndpointRegistry::get_last_committed_txid_v1 ( ccf::View view,
ccf::SeqNo seqno 
)

Get the ID of latest transaction known to be committed.

◆ get_member_cert_v1()

ApiResult ccf::BaseEndpointRegistry::get_member_cert_v1 ( ccf::kv::ReadOnlyTx tx,
const MemberId member_id,
ccf::crypto::Pem member_cert_pem 
)

Get the certificate (PEM) of a given member id.

◆ get_member_data_v1()

ApiResult ccf::BaseEndpointRegistry::get_member_data_v1 ( ccf::kv::ReadOnlyTx tx,
const MemberId member_id,
nlohmann::json &  member_data 
)

Get the member data associated with a given member id.

◆ get_quote_for_this_node_v1()

ApiResult ccf::BaseEndpointRegistry::get_quote_for_this_node_v1 ( ccf::kv::ReadOnlyTx tx,
QuoteInfo quote_info 
)

Get a quote attesting to the hardware this node is running on.

◆ get_quotes_for_all_trusted_nodes_v1()

ApiResult ccf::BaseEndpointRegistry::get_quotes_for_all_trusted_nodes_v1 ( ccf::kv::ReadOnlyTx tx,
std::map< NodeId, QuoteInfo > &  quotes 
)

Get quotes attesting to the hardware that each node in the service is running on.

◆ get_status_for_txid_v1()

ApiResult ccf::BaseEndpointRegistry::get_status_for_txid_v1 ( ccf::View  view,
ccf::SeqNo  seqno,
ccf::TxStatus tx_status 
)

Get the status of a transaction by ID, provided as a view+seqno pair.

Note that this value is the node's local understanding of the status of that transaction in the network at call time. For a given TxID, the initial status is always UNKNOWN, and eventually becomes COMMITTED or INVALID. See the documentation section titled "Verifying Transactions" for more detail.

    UNKNOWN [Initial status]
     v  ^
   PENDING
   v     v

COMMITTED INVALID [Final statuses]

This status is not sampled atomically per handler: if this is called multiple times in a transaction handler, later calls may see more up to date values than earlier calls. Once a final state (COMMITTED or INVALID) has been reached, no further changes are possible.

See also
ccf::TxStatus

◆ get_untrusted_host_time_v1()

ApiResult ccf::BaseEndpointRegistry::get_untrusted_host_time_v1 ( ::timespec &  time)

Get untrusted time from the host of the currently executing node.

◆ get_user_cert_v1()

ApiResult ccf::BaseEndpointRegistry::get_user_cert_v1 ( ccf::kv::ReadOnlyTx tx,
const UserId user_id,
ccf::crypto::Pem user_cert_pem 
)

Get the certificate (PEM) of a given user id.

◆ get_user_data_v1()

ApiResult ccf::BaseEndpointRegistry::get_user_data_v1 ( ccf::kv::ReadOnlyTx tx,
const UserId user_id,
nlohmann::json &  user_data 
)

Get the user data associated with a given user id.

◆ get_view_for_seqno_v1()

ApiResult ccf::BaseEndpointRegistry::get_view_for_seqno_v1 ( ccf::SeqNo  seqno,
ccf::View view 
)

Get the view associated with a given seqno, to construct a valid TxID.

◆ get_view_history_v1()

ApiResult ccf::BaseEndpointRegistry::get_view_history_v1 ( std::vector< ccf::TxID > &  history,
ccf::View  since = 1 
)

Get the history of the consensus view changes.

Returns the history of view changes since the given view, which defaults to the start of time.

A view change is characterised by the first sequence number in the new view.

◆ get_view_history_v2()

ApiResult ccf::BaseEndpointRegistry::get_view_history_v2 ( std::vector< ccf::TxID > &  history,
ccf::View  since,
ccf::InvalidArgsReason reason 
)

Get the history of the consensus view changes.

Returns the history of view changes since the given view, which defaults to the start of time.

A view change is characterised by the first sequence number in the new view.

Member Data Documentation

◆ context

ccf::AbstractNodeContext& ccf::BaseEndpointRegistry::context
protected

The documentation for this class was generated from the following files: