зеркало из https://github.com/microsoft/CCF.git
Namespace more of the public headers (#6279)
This commit is contained in:
Родитель
e91e6ac2d4
Коммит
dcb13291d2
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [5.0.0-rc0]
|
||||
|
||||
[5.0.0-rc0]: https://github.com/microsoft/CCF/releases/tag/ccf-5.0.0-rc0
|
||||
|
||||
### Added
|
||||
|
||||
- More public namespaces have been moved under `::ccf`
|
||||
- `::ds` is now `ccf::ds`
|
||||
- `::siphash` is now `ccf::siphash`
|
||||
- `::threading` is now `ccf::threading`, and `ccf/ds/thread_ids.h` has moved to `ccf/threading/thread_ids.h`
|
||||
- `::consensus` is now `ccf::consensus`
|
||||
- `::tls` is now `ccf::tls`
|
||||
|
||||
## [5.0.0-dev18]
|
||||
|
||||
[5.0.0-dev18]: https://github.com/microsoft/CCF/releases/tag/ccf-5.0.0-dev18
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace std
|
|||
{
|
||||
size_t operator()(const llvm_vecsmall::SmallVector<T, N>& v) const
|
||||
{
|
||||
static constexpr siphash::SipKey k{
|
||||
static constexpr ccf::siphash::SipKey k{
|
||||
0x7720796f726c694b, 0x2165726568207361};
|
||||
return siphash::siphash<2, 4>(v.data(), v.size(), k);
|
||||
return ccf::siphash::siphash<2, 4>(v.data(), v.size(), k);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
// Dense representation of an ordered set of values, assuming it contains
|
||||
// some contiguous ranges of adjacent values. Stores a sequence of ranges,
|
||||
|
@ -500,7 +500,7 @@ namespace ds
|
|||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <typename T>
|
||||
struct formatter<ds::ContiguousSet<T>>
|
||||
struct formatter<ccf::ds::ContiguousSet<T>>
|
||||
{
|
||||
template <typename ParseContext>
|
||||
constexpr auto parse(ParseContext& ctx)
|
||||
|
@ -509,7 +509,7 @@ struct formatter<ds::ContiguousSet<T>>
|
|||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const ds::ContiguousSet<T>& v, FormatContext& ctx) const
|
||||
auto format(const ccf::ds::ContiguousSet<T>& v, FormatContext& ctx) const
|
||||
{
|
||||
std::vector<std::string> ranges;
|
||||
for (const auto& [from, additional] : v.get_ranges())
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace ds::hashutils
|
||||
namespace ccf::ds::hashutils
|
||||
{
|
||||
template <typename T>
|
||||
inline void hash_combine(size_t& n, const T& v, std::hash<T>& h)
|
||||
|
@ -42,9 +42,9 @@ namespace std
|
|||
{
|
||||
// For cryptographically secure hashing, use SipHash directly with a
|
||||
// secret key. For std::hash, we use this fixed key
|
||||
static constexpr siphash::SipKey k{
|
||||
static constexpr ccf::siphash::SipKey k{
|
||||
0x7720796f726c694b, 0x2165726568207361};
|
||||
return siphash::siphash<2, 4>(v, k);
|
||||
return ccf::siphash::siphash<2, 4>(v, k);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace std
|
|||
{
|
||||
size_t operator()(const std::vector<T>& v) const
|
||||
{
|
||||
return ds::hashutils::hash_container(v);
|
||||
return ccf::ds::hashutils::hash_container(v);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace std
|
|||
{
|
||||
size_t operator()(const std::array<T, N>& v) const
|
||||
{
|
||||
return ds::hashutils::hash_container(v);
|
||||
return ccf::ds::hashutils::hash_container(v);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,10 +74,10 @@ namespace std
|
|||
size_t n = 0x444e414c544f4353;
|
||||
|
||||
std::hash<A> h_a{};
|
||||
ds::hashutils::hash_combine(n, v.first, h_a);
|
||||
ccf::ds::hashutils::hash_combine(n, v.first, h_a);
|
||||
|
||||
std::hash<B> h_b{};
|
||||
ds::hashutils::hash_combine(n, v.second, h_b);
|
||||
ccf::ds::hashutils::hash_combine(n, v.second, h_b);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace std
|
|||
|
||||
}
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
/// Simple, fast constexpr hash function (NOT cryptographically sound)
|
||||
namespace
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
static uint8_t hex_char_to_int(char c)
|
||||
{
|
||||
|
|
|
@ -8,35 +8,38 @@
|
|||
#include <fmt/format.h>
|
||||
#include <sstream>
|
||||
|
||||
/** Represents a field within a JSON object. Tuples of these can be used in
|
||||
* schema generation.
|
||||
*/
|
||||
template <typename T>
|
||||
struct JsonField
|
||||
namespace ccf
|
||||
{
|
||||
using Target = T;
|
||||
char const* name;
|
||||
};
|
||||
|
||||
class JsonParseError : public std::invalid_argument
|
||||
{
|
||||
public:
|
||||
std::vector<std::string> pointer_elements = {};
|
||||
|
||||
using std::invalid_argument::invalid_argument;
|
||||
|
||||
std::string pointer() const
|
||||
/** Represents a field within a JSON object. Tuples of these can be used in
|
||||
* schema generation.
|
||||
*/
|
||||
template <typename T>
|
||||
struct JsonField
|
||||
{
|
||||
return fmt::format(
|
||||
"#/{}",
|
||||
fmt::join(pointer_elements.crbegin(), pointer_elements.crend(), "/"));
|
||||
}
|
||||
using Target = T;
|
||||
char const* name;
|
||||
};
|
||||
|
||||
std::string describe() const
|
||||
class JsonParseError : public std::invalid_argument
|
||||
{
|
||||
return fmt::format("At {}: {}", pointer(), what());
|
||||
}
|
||||
};
|
||||
public:
|
||||
std::vector<std::string> pointer_elements = {};
|
||||
|
||||
using std::invalid_argument::invalid_argument;
|
||||
|
||||
std::string pointer() const
|
||||
{
|
||||
return fmt::format(
|
||||
"#/{}",
|
||||
fmt::join(pointer_elements.crbegin(), pointer_elements.crend(), "/"));
|
||||
}
|
||||
|
||||
std::string describe() const
|
||||
{
|
||||
return fmt::format("At {}: {}", pointer(), what());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
@ -89,7 +92,7 @@ namespace std
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Vector of bytes object \"{}\" is not valid base64", j.dump()));
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +104,7 @@ namespace std
|
|||
|
||||
if (!j.is_array())
|
||||
{
|
||||
throw JsonParseError(
|
||||
throw ccf::JsonParseError(
|
||||
fmt::format("Vector object \"{}\" is not an array", j.dump()));
|
||||
}
|
||||
|
||||
|
@ -111,7 +114,7 @@ namespace std
|
|||
{
|
||||
t.push_back(j.at(i).template get<T>());
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
jpe.pointer_elements.push_back(std::to_string(i));
|
||||
throw;
|
||||
|
@ -398,14 +401,14 @@ namespace std
|
|||
const auto it = j.find(JSON_FIELD); \
|
||||
if (it == j.end()) \
|
||||
{ \
|
||||
throw JsonParseError( \
|
||||
throw ccf::JsonParseError( \
|
||||
"Missing required field '" JSON_FIELD "' in object: " + j.dump()); \
|
||||
} \
|
||||
try \
|
||||
{ \
|
||||
t.C_FIELD = it->get<decltype(TYPE::C_FIELD)>(); \
|
||||
} \
|
||||
catch (JsonParseError & jpe) \
|
||||
catch (ccf::JsonParseError & jpe) \
|
||||
{ \
|
||||
jpe.pointer_elements.push_back(JSON_FIELD); \
|
||||
throw; \
|
||||
|
@ -438,7 +441,7 @@ namespace std
|
|||
#define FILL_SCHEMA_REQUIRED_WITH_RENAMES_FOR_JSON_NEXT( \
|
||||
TYPE, C_FIELD, JSON_FIELD) \
|
||||
j["properties"][JSON_FIELD] = \
|
||||
::ds::json::schema_element<decltype(TYPE::C_FIELD)>(); \
|
||||
ccf::ds::json::schema_element<decltype(TYPE::C_FIELD)>(); \
|
||||
j["required"].push_back(JSON_FIELD);
|
||||
#define FILL_SCHEMA_REQUIRED_WITH_RENAMES_FOR_JSON_FINAL( \
|
||||
TYPE, C_FIELD, JSON_FIELD) \
|
||||
|
@ -452,7 +455,7 @@ namespace std
|
|||
#define FILL_SCHEMA_OPTIONAL_WITH_RENAMES_FOR_JSON_NEXT( \
|
||||
TYPE, C_FIELD, JSON_FIELD) \
|
||||
j["properties"][JSON_FIELD] = \
|
||||
::ds::json::schema_element<decltype(TYPE::C_FIELD)>();
|
||||
ccf::ds::json::schema_element<decltype(TYPE::C_FIELD)>();
|
||||
#define FILL_SCHEMA_OPTIONAL_WITH_RENAMES_FOR_JSON_FINAL( \
|
||||
TYPE, C_FIELD, JSON_FIELD) \
|
||||
FILL_SCHEMA_OPTIONAL_WITH_RENAMES_FOR_JSON_NEXT(TYPE, C_FIELD, JSON_FIELD)
|
||||
|
@ -494,9 +497,9 @@ namespace std
|
|||
TYPE, FIELD, #FIELD)
|
||||
|
||||
#define JSON_FIELD_FOR_JSON_NEXT(TYPE, FIELD) \
|
||||
JsonField<decltype(TYPE::FIELD)>{#FIELD},
|
||||
ccf::JsonField<decltype(TYPE::FIELD)>{#FIELD},
|
||||
#define JSON_FIELD_FOR_JSON_FINAL(TYPE, FIELD) \
|
||||
JsonField<decltype(TYPE::FIELD)> \
|
||||
ccf::JsonField<decltype(TYPE::FIELD)> \
|
||||
{ \
|
||||
# FIELD \
|
||||
}
|
||||
|
@ -723,7 +726,7 @@ namespace std
|
|||
{ \
|
||||
if (!j.is_object()) \
|
||||
{ \
|
||||
throw JsonParseError("Expected object, found: " + j.dump()); \
|
||||
throw ccf::JsonParseError("Expected object, found: " + j.dump()); \
|
||||
} \
|
||||
_FOR_JSON_COUNT_NN(__VA_ARGS__)(POP1)(READ_REQUIRED, TYPE, ##__VA_ARGS__) \
|
||||
} \
|
||||
|
@ -758,7 +761,7 @@ namespace std
|
|||
{ \
|
||||
if (!j.is_object()) \
|
||||
{ \
|
||||
throw JsonParseError("Expected object, found: " + j.dump()); \
|
||||
throw ccf::JsonParseError("Expected object, found: " + j.dump()); \
|
||||
} \
|
||||
_FOR_JSON_COUNT_NN(__VA_ARGS__) \
|
||||
(POP2)(READ_REQUIRED_WITH_RENAMES, TYPE, ##__VA_ARGS__) \
|
||||
|
@ -843,7 +846,7 @@ namespace std
|
|||
}); \
|
||||
if (it == std::end(m)) \
|
||||
{ \
|
||||
throw JsonParseError(fmt::format( \
|
||||
throw ccf::JsonParseError(fmt::format( \
|
||||
"Value {} in enum " #TYPE " has no specified JSON conversion", \
|
||||
(size_t)e)); \
|
||||
} \
|
||||
|
@ -862,7 +865,7 @@ namespace std
|
|||
}); \
|
||||
if (it == std::end(m)) \
|
||||
{ \
|
||||
throw JsonParseError( \
|
||||
throw ccf::JsonParseError( \
|
||||
fmt::format("{} is not convertible to " #TYPE, j.dump())); \
|
||||
} \
|
||||
e = it->first; \
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <nlohmann/json.hpp>
|
||||
#include <set>
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "ccf/ds/enum_formatter.h"
|
||||
#include "ccf/ds/logger_level.h"
|
||||
#include "ccf/ds/thread_ids.h"
|
||||
#include "ccf/threading/thread_ids.h"
|
||||
|
||||
#define FMT_HEADER_ONLY
|
||||
#include <fmt/chrono.h>
|
||||
|
@ -72,7 +72,7 @@ namespace logger
|
|||
else
|
||||
{
|
||||
#ifdef INSIDE_ENCLAVE
|
||||
thread_id = threading::get_current_thread_id();
|
||||
thread_id = ccf::threading::get_current_thread_id();
|
||||
#else
|
||||
thread_id = 100;
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <set>
|
||||
#include <string_view>
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
/**
|
||||
* This namespace contains helper functions, structs, and templates for
|
||||
|
@ -296,7 +296,7 @@ namespace ds
|
|||
}
|
||||
|
||||
return add_schema_to_components(
|
||||
document, ds::json::schema_name<T>(), schema);
|
||||
document, ccf::ds::json::schema_name<T>(), schema);
|
||||
}
|
||||
else if constexpr (
|
||||
nonstd::is_specialization<T, std::map>::value ||
|
||||
|
@ -328,7 +328,7 @@ namespace ds
|
|||
schema["items"] = items;
|
||||
}
|
||||
return add_schema_to_components(
|
||||
document, ds::json::schema_name<T>(), schema);
|
||||
document, ccf::ds::json::schema_name<T>(), schema);
|
||||
}
|
||||
else if constexpr (nonstd::is_specialization<T, std::pair>::value)
|
||||
{
|
||||
|
@ -338,20 +338,21 @@ namespace ds
|
|||
items.push_back(add_schema_component<typename T::second_type>());
|
||||
schema["items"] = items;
|
||||
return add_schema_to_components(
|
||||
document, ds::json::schema_name<T>(), schema);
|
||||
document, ccf::ds::json::schema_name<T>(), schema);
|
||||
}
|
||||
else if constexpr (
|
||||
std::is_same<T, std::string>::value || std::is_arithmetic_v<T> ||
|
||||
std::is_same<T, nlohmann::json>::value ||
|
||||
std::is_same<T, ds::json::JsonSchema>::value)
|
||||
std::is_same<T, ccf::ds::json::JsonSchema>::value)
|
||||
{
|
||||
ds::json::fill_schema<T>(schema);
|
||||
ccf::ds::json::fill_schema<T>(schema);
|
||||
return add_schema_to_components(
|
||||
document, ds::json::schema_name<T>(), schema);
|
||||
document, ccf::ds::json::schema_name<T>(), schema);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto name = sanitise_components_key(ds::json::schema_name<T>());
|
||||
const auto name =
|
||||
sanitise_components_key(ccf::ds::json::schema_name<T>());
|
||||
|
||||
auto& components = access::get_object(document, "components");
|
||||
auto& schemas = access::get_object(components, "schemas");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
// C++ port of reference implementation
|
||||
namespace siphash
|
||||
namespace ccf::siphash
|
||||
{
|
||||
using SipState = uint64_t[4];
|
||||
using SipKey = uint64_t[2];
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace ds
|
||||
namespace ccf::ds
|
||||
{
|
||||
// Inspired by CLI11's AsNumberWithUnit
|
||||
class UnitStringConverter
|
||||
|
@ -212,7 +212,7 @@ namespace ds
|
|||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
template <>
|
||||
struct formatter<ds::SizeString>
|
||||
struct formatter<ccf::ds::SizeString>
|
||||
{
|
||||
template <typename ParseContext>
|
||||
constexpr auto parse(ParseContext& ctx)
|
||||
|
@ -221,7 +221,7 @@ struct formatter<ds::SizeString>
|
|||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const ds::SizeString& v, FormatContext& ctx) const
|
||||
auto format(const ccf::ds::SizeString& v, FormatContext& ctx) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << v.str;
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace ccf
|
|||
}
|
||||
else
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"{} should be hex-encoded string: {}",
|
||||
FmtExtender::ID_LABEL,
|
||||
j.dump()));
|
||||
|
|
|
@ -11,27 +11,27 @@ namespace http
|
|||
{
|
||||
// Default parser limits, used as a DoS protection against
|
||||
// requests that are too large.
|
||||
static const ds::SizeString default_max_body_size = {"1MB"};
|
||||
static const ds::SizeString default_max_header_size = {"16KB"};
|
||||
static const ccf::ds::SizeString default_max_body_size = {"1MB"};
|
||||
static const ccf::ds::SizeString default_max_header_size = {"16KB"};
|
||||
static const uint32_t default_max_headers_count = 256;
|
||||
|
||||
// HTTP/2 only, as per nghttp2 defaults
|
||||
static const size_t default_max_concurrent_streams_count = 100;
|
||||
static const ds::SizeString default_initial_window_size = {"64KB"};
|
||||
static const ds::SizeString default_max_frame_size = {"16KB"};
|
||||
static const ccf::ds::SizeString default_initial_window_size = {"64KB"};
|
||||
static const ccf::ds::SizeString default_max_frame_size = {"16KB"};
|
||||
|
||||
struct ParserConfiguration
|
||||
{
|
||||
std::optional<ds::SizeString> max_body_size = std::nullopt;
|
||||
std::optional<ds::SizeString> max_header_size = std::nullopt;
|
||||
std::optional<ccf::ds::SizeString> max_body_size = std::nullopt;
|
||||
std::optional<ccf::ds::SizeString> max_header_size = std::nullopt;
|
||||
std::optional<uint32_t> max_headers_count = std::nullopt;
|
||||
|
||||
// HTTP/2 only
|
||||
std::optional<size_t> max_concurrent_streams_count = std::nullopt;
|
||||
std::optional<ds::SizeString> initial_window_size = std::nullopt;
|
||||
std::optional<ccf::ds::SizeString> initial_window_size = std::nullopt;
|
||||
// Must be between 16KB and 16MB
|
||||
// https://www.rfc-editor.org/rfc/rfc7540#section-4.2
|
||||
std::optional<ds::SizeString> max_frame_size = std::nullopt;
|
||||
std::optional<ccf::ds::SizeString> max_frame_size = std::nullopt;
|
||||
|
||||
bool operator==(const ParserConfiguration& other) const = default;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ struct CCFConfig
|
|||
// 2**24.5 as per RFC8446 Section 5.5
|
||||
size_t node_to_node_message_limit = 23'726'566;
|
||||
|
||||
consensus::Configuration consensus = {};
|
||||
ccf::consensus::Configuration consensus = {};
|
||||
ccf::NodeInfoNetwork network = {};
|
||||
|
||||
struct NodeCertificateInfo
|
||||
|
@ -39,7 +39,7 @@ struct CCFConfig
|
|||
struct LedgerSignatures
|
||||
{
|
||||
size_t tx_count = 5000;
|
||||
ds::TimeString delay = {"1000ms"};
|
||||
ccf::ds::TimeString delay = {"1000ms"};
|
||||
|
||||
bool operator==(const LedgerSignatures&) const = default;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ struct CCFConfig
|
|||
|
||||
struct JWT
|
||||
{
|
||||
ds::TimeString key_refresh_interval = {"30min"};
|
||||
ccf::ds::TimeString key_refresh_interval = {"30min"};
|
||||
|
||||
bool operator==(const JWT&) const = default;
|
||||
};
|
||||
|
@ -102,7 +102,7 @@ struct StartupConfig : CCFConfig
|
|||
struct Join
|
||||
{
|
||||
ccf::NodeInfoNetwork::NetAddress target_rpc_address;
|
||||
ds::TimeString retry_timeout = {"1000ms"};
|
||||
ccf::ds::TimeString retry_timeout = {"1000ms"};
|
||||
std::vector<uint8_t> service_cert = {};
|
||||
bool follow_redirect = true;
|
||||
};
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace ccf::pal
|
|||
}
|
||||
else
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Attestation measurement should be hex-encoded string: {}", j.dump()));
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace kv::serialisers
|
|||
const SerialisedEntry& data)
|
||||
{
|
||||
ccf::pal::AttestationMeasurement<N> ret;
|
||||
ds::from_hex(std::string(data.data(), data.end()), ret.measurement);
|
||||
ccf::ds::from_hex(std::string(data.data(), data.end()), ret.measurement);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,19 +12,19 @@
|
|||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace tls
|
||||
{
|
||||
class Context;
|
||||
using ConnID = int64_t;
|
||||
}
|
||||
|
||||
namespace ccf
|
||||
{
|
||||
namespace tls
|
||||
{
|
||||
class Context;
|
||||
using ConnID = int64_t;
|
||||
}
|
||||
|
||||
class CustomProtocolSubsystemInterface : public AbstractNodeSubSystem
|
||||
{
|
||||
public:
|
||||
using CreateSessionFn = std::function<std::shared_ptr<Session>(
|
||||
tls::ConnID, const std::unique_ptr<tls::Context>&&)>;
|
||||
ccf::tls::ConnID, const std::unique_ptr<tls::Context>&&)>;
|
||||
|
||||
virtual ~CustomProtocolSubsystemInterface() = default;
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace ccf
|
|||
|
||||
virtual std::shared_ptr<Session> create_session(
|
||||
const std::string& protocol_name,
|
||||
tls::ConnID conn_id,
|
||||
ccf::tls::ConnID conn_id,
|
||||
const std::unique_ptr<tls::Context>&& ctx) = 0;
|
||||
|
||||
struct Essentials
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace ccf
|
|||
{
|
||||
static inline llhttp_method http_method_from_str(const std::string_view& s)
|
||||
{
|
||||
const auto hashed_name = ds::fnv_1a<size_t>(s);
|
||||
const auto hashed_name = ccf::ds::fnv_1a<size_t>(s);
|
||||
|
||||
#define XX(num, name, string) \
|
||||
case (ds::fnv_1a<size_t>(#string)): \
|
||||
case (ccf::ds::fnv_1a<size_t>(#string)): \
|
||||
{ \
|
||||
return llhttp_method(num); \
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
|
||||
namespace ccf
|
||||
{
|
||||
using SeqNoCollection = ds::ContiguousSet<ccf::SeqNo>;
|
||||
using SeqNoCollection = ccf::ds::ContiguousSet<ccf::SeqNo>;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
#include "ccf/ds/unit_strings.h"
|
||||
#include "ccf/service/consensus_type.h"
|
||||
|
||||
namespace consensus
|
||||
namespace ccf::consensus
|
||||
{
|
||||
struct Configuration
|
||||
{
|
||||
ds::TimeString message_timeout = {"100ms"};
|
||||
ds::TimeString election_timeout = {"5000ms"};
|
||||
ccf::ds::TimeString message_timeout = {"100ms"};
|
||||
ccf::ds::TimeString election_timeout = {"5000ms"};
|
||||
size_t max_uncommitted_tx_count = 10000;
|
||||
|
||||
bool operator==(const Configuration&) const = default;
|
||||
|
|
|
@ -245,14 +245,14 @@ namespace ccf
|
|||
from_json(j, v2);
|
||||
nin = NodeInfoNetwork(v2);
|
||||
}
|
||||
catch (const JsonParseError& jpe)
|
||||
catch (const ccf::JsonParseError& jpe)
|
||||
{
|
||||
NodeInfoNetwork_v1 v1;
|
||||
try
|
||||
{
|
||||
from_json(j, v1);
|
||||
}
|
||||
catch (const JsonParseError& _)
|
||||
catch (const ccf::JsonParseError& _)
|
||||
{
|
||||
// If this also fails to parse as a v1, then rethrow the earlier error.
|
||||
// Configs should now be using v2, and this v1 parsing is just a
|
||||
|
|
|
@ -91,8 +91,8 @@ namespace ccf
|
|||
auto properties = nlohmann::json::object();
|
||||
{
|
||||
#define XX(field, field_type) \
|
||||
properties[#field] = \
|
||||
ds::openapi::components_ref_object(ds::json::schema_name<field_type>());
|
||||
properties[#field] = ccf::ds::openapi::components_ref_object( \
|
||||
ccf::ds::json::schema_name<field_type>());
|
||||
|
||||
FOREACH_JSENGINE_FIELD(XX)
|
||||
#undef XX
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <map>
|
||||
#include <thread>
|
||||
|
||||
namespace threading
|
||||
namespace ccf::threading
|
||||
{
|
||||
// Assign monotonic thread IDs for display + storage
|
||||
using ThreadID = uint16_t;
|
|
@ -100,14 +100,14 @@ namespace ccf
|
|||
{
|
||||
if (!j.is_string())
|
||||
{
|
||||
throw JsonParseError(
|
||||
throw ccf::JsonParseError(
|
||||
fmt::format("Cannot parse TxID: Expected string, got {}", j.dump()));
|
||||
}
|
||||
|
||||
const auto opt = TxID::from_str(j.get<std::string>());
|
||||
if (!opt.has_value())
|
||||
{
|
||||
throw JsonParseError(fmt::format("Cannot parse TxID: {}", j.dump()));
|
||||
throw ccf::JsonParseError(fmt::format("Cannot parse TxID: {}", j.dump()));
|
||||
}
|
||||
|
||||
tx_id = opt.value();
|
||||
|
|
|
@ -1756,7 +1756,7 @@ namespace loggingapp
|
|||
handle = h(id);
|
||||
for (const auto& seqno : seqnos)
|
||||
{
|
||||
ds::hashutils::hash_combine(handle, seqno, h);
|
||||
ccf::ds::hashutils::hash_combine(handle, seqno, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace client
|
|||
private:
|
||||
crypto::Pem key = {};
|
||||
std::string key_id = "Invalid";
|
||||
std::shared_ptr<tls::Cert> tls_cert = nullptr;
|
||||
std::shared_ptr<::tls::Cert> tls_cert = nullptr;
|
||||
|
||||
// Process reply to an RPC. Records time reply was received. Calls
|
||||
// check_response for derived-overridable validation
|
||||
|
@ -307,8 +307,8 @@ namespace client
|
|||
auto cert_der = crypto::cert_pem_to_der(cert_pem);
|
||||
key_id = crypto::Sha256Hash(cert_der).hex_str();
|
||||
|
||||
tls_cert = std::make_shared<tls::Cert>(
|
||||
std::make_shared<tls::CA>(ca), cert_pem, key);
|
||||
tls_cert = std::make_shared<::tls::Cert>(
|
||||
std::make_shared<::tls::CA>(ca), cert_pem, key);
|
||||
}
|
||||
|
||||
const auto [host, port] = ccf::split_net_address(options.server_address);
|
||||
|
|
|
@ -99,8 +99,8 @@ namespace client
|
|||
HttpRpcTlsClient(
|
||||
const std::string& host,
|
||||
const std::string& port,
|
||||
std::shared_ptr<tls::CA> node_ca = nullptr,
|
||||
std::shared_ptr<tls::Cert> cert = nullptr,
|
||||
std::shared_ptr<::tls::CA> node_ca = nullptr,
|
||||
std::shared_ptr<::tls::Cert> cert = nullptr,
|
||||
const std::string& key_id_ = "Invalid") :
|
||||
TlsClient(host, port, node_ca, cert),
|
||||
parser(*this),
|
||||
|
|
|
@ -68,8 +68,8 @@ namespace client
|
|||
protected:
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::shared_ptr<tls::CA> node_ca;
|
||||
std::shared_ptr<tls::Cert> cert;
|
||||
std::shared_ptr<::tls::CA> node_ca;
|
||||
std::shared_ptr<::tls::Cert> cert;
|
||||
bool connected = false;
|
||||
|
||||
Unique_SSL_CTX ctx;
|
||||
|
@ -119,8 +119,8 @@ namespace client
|
|||
TlsClient(
|
||||
const std::string& host,
|
||||
const std::string& port,
|
||||
std::shared_ptr<tls::CA> node_ca = nullptr,
|
||||
std::shared_ptr<tls::Cert> cert = nullptr) :
|
||||
std::shared_ptr<::tls::CA> node_ca = nullptr,
|
||||
std::shared_ptr<::tls::Cert> cert = nullptr) :
|
||||
host(host),
|
||||
port(port),
|
||||
node_ca(node_ca),
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace aft
|
|||
|
||||
public:
|
||||
Aft(
|
||||
const consensus::Configuration& settings_,
|
||||
const ccf::consensus::Configuration& settings_,
|
||||
std::unique_ptr<Store> store_,
|
||||
std::unique_ptr<LedgerProxy> ledger_,
|
||||
std::shared_ptr<ccf::NodeToNode> channels_,
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace aft
|
|||
DECLARE_JSON_TYPE(RaftHeader<raft_append_entries>)
|
||||
DECLARE_JSON_REQUIRED_FIELDS(RaftHeader<raft_append_entries>, msg)
|
||||
struct AppendEntries : RaftHeader<raft_append_entries>,
|
||||
consensus::AppendEntriesIndex
|
||||
::consensus::AppendEntriesIndex
|
||||
{
|
||||
Term term;
|
||||
Term prev_term;
|
||||
|
@ -141,7 +141,7 @@ namespace aft
|
|||
DECLARE_JSON_TYPE_WITH_2BASES(
|
||||
AppendEntries,
|
||||
RaftHeader<raft_append_entries>,
|
||||
consensus::AppendEntriesIndex);
|
||||
::consensus::AppendEntriesIndex);
|
||||
DECLARE_JSON_REQUIRED_FIELDS(
|
||||
AppendEntries,
|
||||
term,
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace threading
|
|||
std::map<std::thread::id, uint16_t> thread_ids;
|
||||
}
|
||||
|
||||
constexpr auto shash = ds::fnv_1a<size_t>;
|
||||
constexpr auto shash = ccf::ds::fnv_1a<size_t>;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -189,7 +189,7 @@ private:
|
|||
void add_node(ccf::NodeId node_id)
|
||||
{
|
||||
auto kv = std::make_shared<Store>(node_id);
|
||||
const consensus::Configuration settings{{"10ms"}, {"100ms"}};
|
||||
const ccf::consensus::Configuration settings{{"10ms"}, {"100ms"}};
|
||||
auto raft = std::make_shared<TRaft>(
|
||||
settings,
|
||||
std::make_unique<Adaptor>(kv),
|
||||
|
|
|
@ -31,7 +31,7 @@ TEST_CASE("Enclave put")
|
|||
-1, [&](ringbuffer::Message m, const uint8_t* data, size_t size) {
|
||||
switch (m)
|
||||
{
|
||||
case consensus::ledger_append:
|
||||
case ::consensus::ledger_append:
|
||||
{
|
||||
REQUIRE(num_msgs == 0);
|
||||
REQUIRE(serialized::read<bool>(data, size) == globally_committable);
|
||||
|
@ -88,7 +88,7 @@ TEST_CASE("Enclave record")
|
|||
-1, [&](ringbuffer::Message m, const uint8_t* data, size_t size) {
|
||||
switch (m)
|
||||
{
|
||||
case consensus::ledger_append:
|
||||
case ::consensus::ledger_append:
|
||||
{
|
||||
REQUIRE(num_msgs == 0);
|
||||
REQUIRE(serialized::read<bool>(data, size) == globally_committable);
|
||||
|
@ -109,7 +109,7 @@ TEST_CASE("Enclave record")
|
|||
-1, [&](ringbuffer::Message m, const uint8_t* data, size_t size) {
|
||||
switch (m)
|
||||
{
|
||||
case consensus::ledger_append:
|
||||
case ::consensus::ledger_append:
|
||||
{
|
||||
REQUIRE(num_msgs == 0);
|
||||
REQUIRE(serialized::read<bool>(data, size) == globally_committable);
|
||||
|
|
|
@ -14,14 +14,14 @@ using Adaptor = aft::Adaptor<Store>;
|
|||
|
||||
static std::vector<uint8_t> cert;
|
||||
|
||||
static const ds::TimeString request_timeout_ = {"10ms"};
|
||||
static const ds::TimeString election_timeout_ = {"100ms"};
|
||||
static const ccf::ds::TimeString request_timeout_ = {"10ms"};
|
||||
static const ccf::ds::TimeString election_timeout_ = {"100ms"};
|
||||
static const size_t max_uncommitted_tx_count_ = 0;
|
||||
|
||||
static const std::chrono::milliseconds request_timeout = request_timeout_;
|
||||
static const std::chrono::milliseconds election_timeout = election_timeout_;
|
||||
|
||||
static const consensus::Configuration raft_settings{
|
||||
static const ccf::consensus::Configuration raft_settings{
|
||||
request_timeout_, election_timeout_, max_uncommitted_tx_count_};
|
||||
|
||||
static auto hooks = std::make_shared<kv::ConsensusHookPtrs>();
|
||||
|
|
|
@ -10,13 +10,17 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace consensus
|
||||
namespace ccf::consensus
|
||||
{
|
||||
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(Configuration);
|
||||
DECLARE_JSON_REQUIRED_FIELDS(Configuration);
|
||||
DECLARE_JSON_OPTIONAL_FIELDS(
|
||||
Configuration, message_timeout, election_timeout, max_uncommitted_tx_count);
|
||||
|
||||
}
|
||||
|
||||
namespace consensus
|
||||
{
|
||||
#pragma pack(push, 1)
|
||||
template <typename T>
|
||||
struct ConsensusHeader
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace consensus
|
|||
{
|
||||
serializer::ByteRange byte_range = {data, size};
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_append, to_host, globally_committable, byte_range);
|
||||
::consensus::ledger_append, to_host, globally_committable, byte_range);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ namespace consensus
|
|||
void truncate(Index idx)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_truncate, to_host, idx, false /* no recovery */);
|
||||
::consensus::ledger_truncate, to_host, idx, false /* no recovery */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ namespace consensus
|
|||
*/
|
||||
void commit(Index idx)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(consensus::ledger_commit, to_host, idx);
|
||||
RINGBUFFER_WRITE_MESSAGE(::consensus::ledger_commit, to_host, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +124,7 @@ namespace consensus
|
|||
void init(Index idx = 0, Index recovery_start_idx = 0)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_init, to_host, idx, recovery_start_idx);
|
||||
::consensus::ledger_init, to_host, idx, recovery_start_idx);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -43,43 +43,44 @@ namespace consensus
|
|||
}
|
||||
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_get_range,
|
||||
consensus::Index,
|
||||
consensus::Index,
|
||||
consensus::LedgerRequestPurpose);
|
||||
::consensus::ledger_get_range,
|
||||
::consensus::Index,
|
||||
::consensus::Index,
|
||||
::consensus::LedgerRequestPurpose);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_entry_range,
|
||||
consensus::Index,
|
||||
consensus::Index,
|
||||
consensus::LedgerRequestPurpose,
|
||||
::consensus::ledger_entry_range,
|
||||
::consensus::Index,
|
||||
::consensus::Index,
|
||||
::consensus::LedgerRequestPurpose,
|
||||
std::vector<uint8_t>);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_no_entry_range,
|
||||
consensus::Index,
|
||||
consensus::Index,
|
||||
consensus::LedgerRequestPurpose);
|
||||
::consensus::ledger_no_entry_range,
|
||||
::consensus::Index,
|
||||
::consensus::Index,
|
||||
::consensus::LedgerRequestPurpose);
|
||||
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_init,
|
||||
consensus::Index /* start idx */,
|
||||
consensus::Index /* recovery start idx */);
|
||||
::consensus::ledger_init,
|
||||
::consensus::Index /* start idx */,
|
||||
::consensus::Index /* recovery start idx */);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_append, bool /* committable */, std::vector<uint8_t>);
|
||||
::consensus::ledger_append, bool /* committable */, std::vector<uint8_t>);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::ledger_truncate, consensus::Index, bool /* recovery mode */);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(consensus::ledger_commit, consensus::Index);
|
||||
DECLARE_RINGBUFFER_MESSAGE_NO_PAYLOAD(consensus::ledger_open);
|
||||
::consensus::ledger_truncate, ::consensus::Index, bool /* recovery mode */);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::snapshot_allocate,
|
||||
consensus::Index /* snapshot idx */,
|
||||
consensus::Index /* evidence idx */,
|
||||
::consensus::ledger_commit, ::consensus::Index);
|
||||
DECLARE_RINGBUFFER_MESSAGE_NO_PAYLOAD(::consensus::ledger_open);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
::consensus::snapshot_allocate,
|
||||
::consensus::Index /* snapshot idx */,
|
||||
::consensus::Index /* evidence idx */,
|
||||
size_t /* size to allocate */,
|
||||
uint32_t /* unique request id */);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::snapshot_allocated,
|
||||
::consensus::snapshot_allocated,
|
||||
std::span<uint8_t>, /* span to host-allocated memory for snapshot */
|
||||
uint32_t /* unique request id */);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
consensus::snapshot_commit,
|
||||
consensus::Index /* snapshot idx */,
|
||||
::consensus::snapshot_commit,
|
||||
::consensus::Index /* snapshot idx */,
|
||||
std::vector<uint8_t> /* serialised receipt */);
|
||||
|
|
|
@ -60,13 +60,13 @@ namespace crypto
|
|||
|
||||
std::string Sha256Hash::hex_str() const
|
||||
{
|
||||
return ds::to_hex(h);
|
||||
return ccf::ds::to_hex(h);
|
||||
}
|
||||
|
||||
Sha256Hash Sha256Hash::from_hex_string(const std::string& str)
|
||||
{
|
||||
Sha256Hash digest;
|
||||
ds::from_hex(str, digest.h);
|
||||
ccf::ds::from_hex(str, digest.h);
|
||||
return digest;
|
||||
}
|
||||
|
||||
|
@ -94,11 +94,11 @@ namespace crypto
|
|||
auto value = j.get<std::string>();
|
||||
try
|
||||
{
|
||||
ds::from_hex(value, hash.h);
|
||||
ccf::ds::from_hex(value, hash.h);
|
||||
}
|
||||
catch (const std::logic_error& e)
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Input string \"{}\" is not valid hex-encoded SHA-256: {}",
|
||||
value,
|
||||
e.what()));
|
||||
|
|
|
@ -13,7 +13,7 @@ TEST_CASE("Simple key exchange")
|
|||
INFO("Try to compute shared secret before peer public have been exchanged");
|
||||
{
|
||||
// These key exchange contexts should not be used after negative testing.
|
||||
tls::KeyExchangeContext peer1_ctx, peer2_ctx;
|
||||
::tls::KeyExchangeContext peer1_ctx, peer2_ctx;
|
||||
|
||||
// Cannot compute the shared secret until the peer's public has been
|
||||
// loaded
|
||||
|
@ -33,7 +33,7 @@ TEST_CASE("Simple key exchange")
|
|||
|
||||
INFO("Compute shared secret");
|
||||
{
|
||||
tls::KeyExchangeContext peer1_ctx, peer2_ctx;
|
||||
::tls::KeyExchangeContext peer1_ctx, peer2_ctx;
|
||||
auto peer1_public = peer1_ctx.get_own_key_share();
|
||||
auto peer2_public = peer2_ctx.get_own_key_share();
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace ringbuffer
|
|||
|
||||
/// Useful machinery
|
||||
#define DEFINE_RINGBUFFER_MSG_TYPE(NAME) \
|
||||
NAME = ds::fnv_1a<ringbuffer::Message>(#NAME)
|
||||
NAME = ccf::ds::fnv_1a<ringbuffer::Message>(#NAME)
|
||||
|
||||
template <ringbuffer::Message m>
|
||||
struct MessageSerializers
|
||||
|
|
|
@ -25,7 +25,7 @@ void test(T from, T to)
|
|||
std::mt19937 g(rd());
|
||||
std::shuffle(sample.begin(), sample.end(), g);
|
||||
|
||||
ds::ContiguousSet<T> cs;
|
||||
ccf::ds::ContiguousSet<T> cs;
|
||||
for (const auto& n : sample)
|
||||
{
|
||||
REQUIRE(cs.insert(n));
|
||||
|
@ -59,7 +59,7 @@ void test(T from, T to)
|
|||
TEST_CASE_TEMPLATE(
|
||||
"Contiguous set API" * doctest::test_suite("contiguousset"), T, size_t, int)
|
||||
{
|
||||
ds::ContiguousSet<T> cs;
|
||||
ccf::ds::ContiguousSet<T> cs;
|
||||
const auto& ccs = cs;
|
||||
|
||||
T a, b, c;
|
||||
|
@ -103,7 +103,7 @@ TEST_CASE_TEMPLATE(
|
|||
REQUIRE(ccs.front() == ccs.back());
|
||||
|
||||
{
|
||||
ds::ContiguousSet<T> cs2(ccs);
|
||||
ccf::ds::ContiguousSet<T> cs2(ccs);
|
||||
REQUIRE(cs == cs2);
|
||||
|
||||
REQUIRE(cs2.erase(b));
|
||||
|
@ -219,7 +219,7 @@ TEST_CASE_TEMPLATE(
|
|||
|
||||
TEST_CASE("Contiguous set single range" * doctest::test_suite("contiguousset"))
|
||||
{
|
||||
ds::ContiguousSet<size_t> cs;
|
||||
ccf::ds::ContiguousSet<size_t> cs;
|
||||
|
||||
cs.insert(5);
|
||||
cs.insert(6);
|
||||
|
@ -231,7 +231,7 @@ TEST_CASE("Contiguous set single range" * doctest::test_suite("contiguousset"))
|
|||
|
||||
TEST_CASE("Contiguous set explicit test" * doctest::test_suite("contiguousset"))
|
||||
{
|
||||
ds::ContiguousSet<size_t> cs;
|
||||
ccf::ds::ContiguousSet<size_t> cs;
|
||||
|
||||
REQUIRE(cs.insert(10));
|
||||
REQUIRE(cs.insert(8));
|
||||
|
@ -337,7 +337,7 @@ TEST_CASE("Contiguous set explicit test" * doctest::test_suite("contiguousset"))
|
|||
|
||||
TEST_CASE("Contiguous set iterators" * doctest::test_suite("contiguousset"))
|
||||
{
|
||||
ds::ContiguousSet<size_t> cs;
|
||||
ccf::ds::ContiguousSet<size_t> cs;
|
||||
|
||||
REQUIRE(cs.insert(5));
|
||||
REQUIRE(cs.insert(9));
|
||||
|
@ -432,7 +432,7 @@ TEST_CASE("Contiguous set iterators" * doctest::test_suite("contiguousset"))
|
|||
TEST_CASE(
|
||||
"Contiguous set range construction" * doctest::test_suite("contiguousset"))
|
||||
{
|
||||
ds::ContiguousSet<size_t> cs;
|
||||
ccf::ds::ContiguousSet<size_t> cs;
|
||||
|
||||
REQUIRE(cs.insert(5));
|
||||
REQUIRE(cs.insert(6));
|
||||
|
@ -446,42 +446,42 @@ TEST_CASE(
|
|||
REQUIRE(cs.insert(26));
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.begin(), cs.end());
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.begin(), cs.end());
|
||||
REQUIRE(cs == subrange);
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.begin(), cs.begin());
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.begin(), cs.begin());
|
||||
REQUIRE(subrange.empty());
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.end(), cs.end());
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.end(), cs.end());
|
||||
REQUIRE(subrange.empty());
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(6));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(6));
|
||||
REQUIRE(subrange.size() == 1);
|
||||
REQUIRE(subrange.contains(5));
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.begin(), cs.find(9));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.begin(), cs.find(9));
|
||||
REQUIRE(subrange.size() == 2);
|
||||
REQUIRE(subrange.contains(5));
|
||||
REQUIRE(subrange.contains(6));
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(9));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(9));
|
||||
REQUIRE(subrange.size() == 2);
|
||||
REQUIRE(subrange.contains(5));
|
||||
REQUIRE(subrange.contains(6));
|
||||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(10));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(5), cs.find(10));
|
||||
REQUIRE(subrange.size() == 3);
|
||||
REQUIRE(subrange.contains(5));
|
||||
REQUIRE(subrange.contains(6));
|
||||
|
@ -489,7 +489,7 @@ TEST_CASE(
|
|||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(11));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(11));
|
||||
REQUIRE(subrange.size() == 3);
|
||||
REQUIRE(subrange.contains(6));
|
||||
REQUIRE(subrange.contains(9));
|
||||
|
@ -497,7 +497,7 @@ TEST_CASE(
|
|||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(25));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(25));
|
||||
REQUIRE(subrange.size() == 7);
|
||||
REQUIRE(subrange.contains(6));
|
||||
REQUIRE(subrange.contains(9));
|
||||
|
@ -509,7 +509,7 @@ TEST_CASE(
|
|||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(26));
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(6), cs.find(26));
|
||||
REQUIRE(subrange.size() == 8);
|
||||
REQUIRE(subrange.contains(6));
|
||||
REQUIRE(subrange.contains(9));
|
||||
|
@ -522,7 +522,7 @@ TEST_CASE(
|
|||
}
|
||||
|
||||
{
|
||||
ds::ContiguousSet<size_t> subrange(cs.find(6), cs.end());
|
||||
ccf::ds::ContiguousSet<size_t> subrange(cs.find(6), cs.end());
|
||||
REQUIRE(subrange.size() == 9);
|
||||
REQUIRE(subrange.contains(6));
|
||||
REQUIRE(subrange.contains(9));
|
||||
|
@ -553,7 +553,7 @@ TEST_CASE("Contiguous set scale" * doctest::test_suite("contiguousset"))
|
|||
|
||||
TEST_CASE("Contiguous set extend" * doctest::test_suite("contiguousset"))
|
||||
{
|
||||
ds::ContiguousSet<size_t> cs;
|
||||
ccf::ds::ContiguousSet<size_t> cs;
|
||||
|
||||
// Distinct range at beginning
|
||||
cs.extend(5, 1);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
TEST_CASE("SipHash-2-4 correctness" * doctest::test_suite("hash"))
|
||||
{
|
||||
siphash::SipKey key{
|
||||
siphash::bytes_to_64_le("\000\001\002\003\004\005\006\007"),
|
||||
siphash::bytes_to_64_le("\010\011\012\013\014\015\016\017")};
|
||||
ccf::siphash::SipKey key{
|
||||
ccf::siphash::bytes_to_64_le("\000\001\002\003\004\005\006\007"),
|
||||
ccf::siphash::bytes_to_64_le("\010\011\012\013\014\015\016\017")};
|
||||
|
||||
std::vector<uint8_t> in;
|
||||
|
||||
|
@ -21,10 +21,10 @@ TEST_CASE("SipHash-2-4 correctness" * doctest::test_suite("hash"))
|
|||
{
|
||||
const auto& expected = siphash_2_4_vectors[i];
|
||||
|
||||
auto out = siphash::siphash<2, 4>(in, key);
|
||||
auto out = ccf::siphash::siphash<2, 4>(in, key);
|
||||
uint8_t actual[8];
|
||||
|
||||
siphash::u64_to_bytes_le(out, actual);
|
||||
ccf::siphash::u64_to_bytes_le(out, actual);
|
||||
|
||||
for (auto j = 0; j < 8; ++j)
|
||||
{
|
||||
|
@ -119,8 +119,8 @@ TEST_CASE("std::pair hash" * doctest::test_suite("hash"))
|
|||
}
|
||||
}
|
||||
|
||||
constexpr auto fnv_1a_32 = ds::fnv_1a<uint32_t>;
|
||||
constexpr auto fnv_1a_64 = ds::fnv_1a<uint64_t>;
|
||||
constexpr auto fnv_1a_32 = ccf::ds::fnv_1a<uint32_t>;
|
||||
constexpr auto fnv_1a_64 = ccf::ds::fnv_1a<uint64_t>;
|
||||
|
||||
TEST_CASE("FNV-1a correctness" * doctest::test_suite("hash"))
|
||||
{
|
||||
|
|
|
@ -17,17 +17,17 @@ TEST_CASE("Hex string to and from conversion")
|
|||
INFO("Simple test");
|
||||
|
||||
std::string valid_hex_str("0123456789abcdef");
|
||||
auto data = ds::from_hex(valid_hex_str);
|
||||
auto data = ccf::ds::from_hex(valid_hex_str);
|
||||
REQUIRE(data.size() == valid_hex_str.size() / 2);
|
||||
REQUIRE(ds::to_hex(data) == valid_hex_str);
|
||||
REQUIRE(ccf::ds::to_hex(data) == valid_hex_str);
|
||||
}
|
||||
|
||||
{
|
||||
INFO("Invalid length");
|
||||
|
||||
REQUIRE_THROWS(ds::from_hex("a"));
|
||||
REQUIRE_THROWS(ds::from_hex("abc"));
|
||||
REQUIRE_THROWS(ds::from_hex("abcde"));
|
||||
REQUIRE_THROWS(ccf::ds::from_hex("a"));
|
||||
REQUIRE_THROWS(ccf::ds::from_hex("abc"));
|
||||
REQUIRE_THROWS(ccf::ds::from_hex("abcde"));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -37,8 +37,8 @@ TEST_CASE("Hex string to and from conversion")
|
|||
std::string lowercase_hex_str = uppercase_hex_str;
|
||||
nonstd::to_lower(lowercase_hex_str);
|
||||
|
||||
auto data = ds::from_hex(uppercase_hex_str);
|
||||
auto data = ccf::ds::from_hex(uppercase_hex_str);
|
||||
REQUIRE(data.size() == uppercase_hex_str.size() / 2);
|
||||
REQUIRE(ds::to_hex(data) == lowercase_hex_str);
|
||||
REQUIRE(ccf::ds::to_hex(data) == lowercase_hex_str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ DECLARE_JSON_OPTIONAL_FIELDS(Foo, n_1, s_1, opt, vec_s);
|
|||
|
||||
TEST_CASE("schema generation")
|
||||
{
|
||||
const auto schema = ds::json::build_schema<Foo>("Foo");
|
||||
const auto schema = ccf::ds::json::build_schema<Foo>("Foo");
|
||||
|
||||
const auto title_it = schema.find("title");
|
||||
REQUIRE(title_it != schema.end());
|
||||
|
@ -175,7 +175,7 @@ TEST_CASE("schema generation")
|
|||
TEST_CASE_TEMPLATE("schema types, integer", T, size_t, ssize_t)
|
||||
{
|
||||
std::map<T, std::string> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
|
||||
REQUIRE(schema["type"] == "array");
|
||||
REQUIRE(schema["items"].is_object());
|
||||
|
@ -190,7 +190,7 @@ TEST_CASE_TEMPLATE("schema types, integer", T, size_t, ssize_t)
|
|||
TEST_CASE_TEMPLATE("schema types, floating point", T, float, double)
|
||||
{
|
||||
std::map<size_t, T> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
|
||||
REQUIRE(schema["type"] == "array");
|
||||
REQUIRE(schema["items"].is_object());
|
||||
|
@ -233,11 +233,11 @@ namespace custom
|
|||
TEST_CASE("custom elements")
|
||||
{
|
||||
const auto x_schema =
|
||||
ds::json::build_schema<custom::user::defined::X>("custom-x");
|
||||
ccf::ds::json::build_schema<custom::user::defined::X>("custom-x");
|
||||
REQUIRE(x_schema["format"] == "email");
|
||||
|
||||
const auto y_schema =
|
||||
ds::json::build_schema<custom::user::defined::Y>("custom-y");
|
||||
ccf::ds::json::build_schema<custom::user::defined::Y>("custom-y");
|
||||
REQUIRE(y_schema["required"].size() == 2);
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ TEST_CASE("nested")
|
|||
{
|
||||
invalid_json.get<Nest3>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
REQUIRE(jpe.pointer() == "#/v/xs/3/a");
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ TEST_CASE("nested")
|
|||
{
|
||||
invalid_json.get<Nest3>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
REQUIRE(jpe.pointer() == "#/v/xs/3");
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ TEST_CASE("nested")
|
|||
{
|
||||
invalid_json.get<Nest3>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
REQUIRE(jpe.pointer() == "#/v/xs/3");
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ TEST_CASE("nested")
|
|||
{
|
||||
invalid_json.get<Nest3>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
REQUIRE(jpe.pointer() == "#/v/xs");
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ TEST_CASE("nested")
|
|||
{
|
||||
invalid_json.get<Nest3>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
REQUIRE(jpe.pointer() == "#/v");
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ TEST_CASE("enum")
|
|||
|
||||
REQUIRE(j["se"] == "two");
|
||||
|
||||
const auto schema = ds::json::build_schema<EnumStruct>("EnumStruct");
|
||||
const auto schema = ccf::ds::json::build_schema<EnumStruct>("EnumStruct");
|
||||
|
||||
const nlohmann::json expected{"one", "two", "three"};
|
||||
REQUIRE(schema["properties"]["se"]["enum"] == expected);
|
||||
|
@ -488,7 +488,7 @@ TEST_CASE("mappings")
|
|||
{
|
||||
INFO("string-keyed maps");
|
||||
std::map<std::string, size_t> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
REQUIRE(schema["type"] == "object");
|
||||
|
||||
m["foo"] = 42;
|
||||
|
@ -499,7 +499,7 @@ TEST_CASE("mappings")
|
|||
{
|
||||
INFO("num-keyed maps");
|
||||
std::map<size_t, size_t> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
REQUIRE(schema["type"] == "array");
|
||||
|
||||
m[5] = 42;
|
||||
|
@ -510,7 +510,7 @@ TEST_CASE("mappings")
|
|||
{
|
||||
INFO("stringable-keyed maps");
|
||||
std::map<Stringable, size_t> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
REQUIRE(schema["type"] == "object");
|
||||
|
||||
Stringable foo("foo");
|
||||
|
@ -524,7 +524,7 @@ TEST_CASE("mappings")
|
|||
{
|
||||
INFO("enum-keyed maps");
|
||||
std::map<EnumStruct::SampleEnum, size_t> m;
|
||||
const auto schema = ds::json::build_schema<decltype(m)>("Map");
|
||||
const auto schema = ccf::ds::json::build_schema<decltype(m)>("Map");
|
||||
REQUIRE(schema["type"] == "array");
|
||||
|
||||
m[EnumStruct::SampleEnum::One] = 42;
|
||||
|
@ -588,7 +588,7 @@ namespace renamed
|
|||
|
||||
TEST_CASE("JSON with different field names")
|
||||
{
|
||||
const auto schema = ds::json::build_schema<renamed::Foo>("renamed::Foo");
|
||||
const auto schema = ccf::ds::json::build_schema<renamed::Foo>("renamed::Foo");
|
||||
|
||||
const auto& properties = schema["properties"];
|
||||
const auto& required = schema["required"];
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
using namespace ds;
|
||||
using namespace ccf::ds;
|
||||
|
||||
#define REQUIRE_ELEMENT(j, name, type_fn) \
|
||||
{ \
|
||||
|
@ -260,7 +260,7 @@ TEST_CASE("Manual function definitions")
|
|||
|
||||
TEST_CASE("sanitise_components_key")
|
||||
{
|
||||
using namespace ds::openapi;
|
||||
using namespace ccf::ds::openapi;
|
||||
|
||||
CHECK(sanitise_components_key("User") == "User");
|
||||
CHECK(sanitise_components_key("User_1") == "User_1");
|
||||
|
|
|
@ -23,12 +23,12 @@ struct Foo
|
|||
|
||||
size_t Foo::count = 0;
|
||||
|
||||
static void always(std::unique_ptr<threading::Tmsg<Foo>> msg)
|
||||
static void always(std::unique_ptr<::threading::Tmsg<Foo>> msg)
|
||||
{
|
||||
msg->data.happened = true;
|
||||
}
|
||||
|
||||
static void never(std::unique_ptr<threading::Tmsg<Foo>> msg)
|
||||
static void never(std::unique_ptr<::threading::Tmsg<Foo>> msg)
|
||||
{
|
||||
CHECK(false);
|
||||
}
|
||||
|
@ -36,20 +36,21 @@ static void never(std::unique_ptr<threading::Tmsg<Foo>> msg)
|
|||
TEST_CASE("ThreadMessaging API" * doctest::test_suite("threadmessaging"))
|
||||
{
|
||||
{
|
||||
threading::ThreadMessaging tm(1);
|
||||
::threading::ThreadMessaging tm(1);
|
||||
|
||||
static constexpr auto worker_thread_id = threading::MAIN_THREAD_ID + 1;
|
||||
static constexpr auto worker_thread_id = ccf::threading::MAIN_THREAD_ID + 1;
|
||||
|
||||
bool happened_main_thread = false;
|
||||
bool happened_worker_thread = false;
|
||||
|
||||
tm.add_task<Foo>(
|
||||
threading::MAIN_THREAD_ID,
|
||||
std::make_unique<threading::Tmsg<Foo>>(&always, happened_main_thread));
|
||||
ccf::threading::MAIN_THREAD_ID,
|
||||
std::make_unique<::threading::Tmsg<Foo>>(&always, happened_main_thread));
|
||||
|
||||
REQUIRE_THROWS(tm.add_task<Foo>(
|
||||
worker_thread_id,
|
||||
std::make_unique<threading::Tmsg<Foo>>(&always, happened_worker_thread)));
|
||||
std::make_unique<::threading::Tmsg<Foo>>(
|
||||
&always, happened_worker_thread)));
|
||||
|
||||
REQUIRE(tm.run_one());
|
||||
REQUIRE_FALSE(tm.run_one());
|
||||
|
@ -61,9 +62,9 @@ TEST_CASE("ThreadMessaging API" * doctest::test_suite("threadmessaging"))
|
|||
{
|
||||
// Create a ThreadMessaging with task queues for main thread + 1 worker
|
||||
// thread
|
||||
threading::ThreadMessaging tm(2);
|
||||
::threading::ThreadMessaging tm(2);
|
||||
|
||||
static constexpr auto worker_a_id = threading::MAIN_THREAD_ID + 1;
|
||||
static constexpr auto worker_a_id = ccf::threading::MAIN_THREAD_ID + 1;
|
||||
static constexpr auto worker_b_id = worker_a_id + 1;
|
||||
|
||||
bool happened_0 = false;
|
||||
|
@ -74,21 +75,23 @@ TEST_CASE("ThreadMessaging API" * doctest::test_suite("threadmessaging"))
|
|||
// Queue single task for main thread:
|
||||
// - set happened_0
|
||||
tm.add_task<Foo>(
|
||||
threading::MAIN_THREAD_ID,
|
||||
ccf::threading::MAIN_THREAD_ID,
|
||||
std::make_unique<threading::Tmsg<Foo>>(&always, happened_0));
|
||||
|
||||
// Queue 2 tasks for worker a:
|
||||
// - set happened_1
|
||||
// - set happened_2
|
||||
tm.add_task<Foo>(
|
||||
worker_a_id, std::make_unique<threading::Tmsg<Foo>>(&always, happened_1));
|
||||
worker_a_id,
|
||||
std::make_unique<::threading::Tmsg<Foo>>(&always, happened_1));
|
||||
tm.add_task<Foo>(
|
||||
worker_a_id, std::make_unique<threading::Tmsg<Foo>>(&always, happened_2));
|
||||
worker_a_id,
|
||||
std::make_unique<::threading::Tmsg<Foo>>(&always, happened_2));
|
||||
|
||||
// Fail to queue task for worker b, tm is too small
|
||||
REQUIRE_THROWS(tm.add_task<Foo>(
|
||||
worker_b_id,
|
||||
std::make_unique<threading::Tmsg<Foo>>(&always, happened_3)));
|
||||
std::make_unique<::threading::Tmsg<Foo>>(&always, happened_3)));
|
||||
|
||||
// Run single task on main thread
|
||||
REQUIRE(tm.run_one());
|
||||
|
@ -103,7 +106,7 @@ TEST_CASE("ThreadMessaging API" * doctest::test_suite("threadmessaging"))
|
|||
|
||||
std::thread t([&]() {
|
||||
// Run tasks for worker "a"
|
||||
REQUIRE(threading::get_current_thread_id() == worker_a_id);
|
||||
REQUIRE(ccf::threading::get_current_thread_id() == worker_a_id);
|
||||
|
||||
REQUIRE(tm.run_one());
|
||||
REQUIRE(happened_1);
|
||||
|
@ -132,16 +135,16 @@ TEST_CASE(
|
|||
bool happened = false;
|
||||
|
||||
{
|
||||
threading::ThreadMessaging tm(1);
|
||||
::threading::ThreadMessaging tm(1);
|
||||
|
||||
auto m1 = std::make_unique<threading::Tmsg<Foo>>(&always, happened);
|
||||
auto m1 = std::make_unique<::threading::Tmsg<Foo>>(&always, happened);
|
||||
tm.add_task<Foo>(0, std::move(m1));
|
||||
|
||||
// Task payload (and TMsg) is freed after running
|
||||
tm.run_one();
|
||||
CHECK(Foo::count == 0);
|
||||
|
||||
auto m2 = std::make_unique<threading::Tmsg<Foo>>(&never, happened);
|
||||
auto m2 = std::make_unique<::threading::Tmsg<Foo>>(&never, happened);
|
||||
tm.add_task<Foo>(0, std::move(m2));
|
||||
// Task is owned by the queue, hasn't run
|
||||
CHECK(Foo::count == 1);
|
||||
|
@ -158,14 +161,14 @@ TEST_CASE("Unique thread IDs" * doctest::test_suite("threadmessaging"))
|
|||
std::mutex assigned_ids_lock;
|
||||
std::vector<uint16_t> assigned_ids;
|
||||
|
||||
const auto main_thread_id = threading::get_current_thread_id();
|
||||
REQUIRE(main_thread_id == threading::MAIN_THREAD_ID);
|
||||
const auto main_thread_id = ccf::threading::get_current_thread_id();
|
||||
REQUIRE(main_thread_id == ccf::threading::MAIN_THREAD_ID);
|
||||
assigned_ids.push_back(main_thread_id);
|
||||
|
||||
auto fn = [&]() {
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(assigned_ids_lock);
|
||||
const auto current_thread_id = threading::get_current_thread_id();
|
||||
const auto current_thread_id = ccf::threading::get_current_thread_id();
|
||||
assigned_ids.push_back(current_thread_id);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <cmath>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
using namespace ds;
|
||||
using namespace ccf::ds;
|
||||
|
||||
TEST_CASE("Size strings" * doctest::test_suite("unit strings"))
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "ccf/ccf_assert.h"
|
||||
#include "ccf/ds/logger.h"
|
||||
#include "ccf/ds/thread_ids.h"
|
||||
#include "ccf/threading/thread_ids.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
@ -294,7 +294,7 @@ namespace threading
|
|||
|
||||
void run()
|
||||
{
|
||||
TaskQueue& task = get_tasks(get_current_thread_id());
|
||||
TaskQueue& task = get_tasks(ccf::threading::get_current_thread_id());
|
||||
|
||||
while (!is_finished())
|
||||
{
|
||||
|
@ -304,7 +304,7 @@ namespace threading
|
|||
|
||||
bool run_one()
|
||||
{
|
||||
TaskQueue& task = get_tasks(get_current_thread_id());
|
||||
TaskQueue& task = get_tasks(ccf::threading::get_current_thread_id());
|
||||
return task.run_next_task();
|
||||
}
|
||||
|
||||
|
@ -320,19 +320,19 @@ namespace threading
|
|||
TaskQueue::TimerEntry add_task_after(
|
||||
std::unique_ptr<Tmsg<Payload>> msg, std::chrono::milliseconds ms)
|
||||
{
|
||||
TaskQueue& task = get_tasks(get_current_thread_id());
|
||||
TaskQueue& task = get_tasks(ccf::threading::get_current_thread_id());
|
||||
return task.add_task_after(std::move(msg), ms);
|
||||
}
|
||||
|
||||
bool cancel_timer_task(TaskQueue::TimerEntry timer_entry)
|
||||
{
|
||||
TaskQueue& task = get_tasks(get_current_thread_id());
|
||||
TaskQueue& task = get_tasks(ccf::threading::get_current_thread_id());
|
||||
return task.cancel_timer_task(timer_entry);
|
||||
}
|
||||
|
||||
std::chrono::milliseconds get_current_time_offset()
|
||||
{
|
||||
TaskQueue& task = get_tasks(get_current_thread_id());
|
||||
TaskQueue& task = get_tasks(ccf::threading::get_current_thread_id());
|
||||
return task.get_current_time_offset();
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ namespace threading
|
|||
|
||||
uint16_t get_execution_thread(uint32_t i)
|
||||
{
|
||||
uint16_t tid = MAIN_THREAD_ID;
|
||||
uint16_t tid = ccf::threading::MAIN_THREAD_ID;
|
||||
if (tasks.size() > 1)
|
||||
{
|
||||
// If we have multiple task queues, then we distinguish the main thread
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace ccf
|
|||
const HandleErrorCallback e = nullptr)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_connect, to_host, client_session_id, hostname, service);
|
||||
::tls::tls_connect, to_host, client_session_id, hostname, service);
|
||||
handle_data_cb = f;
|
||||
handle_error_cb = e;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace ccf
|
|||
RingbufferLogger* ringbuffer_logger_,
|
||||
size_t sig_tx_interval,
|
||||
size_t sig_ms_interval,
|
||||
const consensus::Configuration& consensus_config,
|
||||
const ccf::consensus::Configuration& consensus_config,
|
||||
const crypto::CurveID& curve_id) :
|
||||
circuit(std::move(circuit_)),
|
||||
basic_writer_factory(std::move(basic_writer_factory_)),
|
||||
|
@ -311,7 +311,7 @@ namespace ccf
|
|||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
bp, AdminMessage::stop, [&bp](const uint8_t*, size_t) {
|
||||
bp.set_finished();
|
||||
threading::ThreadMessaging::instance().set_finished();
|
||||
::threading::ThreadMessaging::instance().set_finished();
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
|
@ -342,7 +342,7 @@ namespace ccf
|
|||
|
||||
node->tick(elapsed_ms);
|
||||
historical_state_cache->tick(elapsed_ms);
|
||||
threading::ThreadMessaging::instance().tick(elapsed_ms);
|
||||
::threading::ThreadMessaging::instance().tick(elapsed_ms);
|
||||
// When recovering, no signature should be emitted while the
|
||||
// public ledger is being read
|
||||
if (!node->is_reading_public_ledger())
|
||||
|
@ -371,14 +371,14 @@ namespace ccf
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
bp,
|
||||
consensus::ledger_entry_range,
|
||||
::consensus::ledger_entry_range,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
const auto [from_seqno, to_seqno, purpose, body] =
|
||||
ringbuffer::read_message<consensus::ledger_entry_range>(
|
||||
ringbuffer::read_message<::consensus::ledger_entry_range>(
|
||||
data, size);
|
||||
switch (purpose)
|
||||
{
|
||||
case consensus::LedgerRequestPurpose::Recovery:
|
||||
case ::consensus::LedgerRequestPurpose::Recovery:
|
||||
{
|
||||
if (node->is_reading_public_ledger())
|
||||
{
|
||||
|
@ -396,7 +396,7 @@ namespace ccf
|
|||
}
|
||||
break;
|
||||
}
|
||||
case consensus::LedgerRequestPurpose::HistoricalQuery:
|
||||
case ::consensus::LedgerRequestPurpose::HistoricalQuery:
|
||||
{
|
||||
historical_state_cache->handle_ledger_entries(
|
||||
from_seqno, to_seqno, body);
|
||||
|
@ -411,19 +411,19 @@ namespace ccf
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
bp,
|
||||
consensus::ledger_no_entry_range,
|
||||
::consensus::ledger_no_entry_range,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
const auto [from_seqno, to_seqno, purpose] =
|
||||
ringbuffer::read_message<consensus::ledger_no_entry_range>(
|
||||
ringbuffer::read_message<::consensus::ledger_no_entry_range>(
|
||||
data, size);
|
||||
switch (purpose)
|
||||
{
|
||||
case consensus::LedgerRequestPurpose::Recovery:
|
||||
case ::consensus::LedgerRequestPurpose::Recovery:
|
||||
{
|
||||
node->recover_ledger_end();
|
||||
break;
|
||||
}
|
||||
case consensus::LedgerRequestPurpose::HistoricalQuery:
|
||||
case ::consensus::LedgerRequestPurpose::HistoricalQuery:
|
||||
{
|
||||
historical_state_cache->handle_no_entry_range(
|
||||
from_seqno, to_seqno);
|
||||
|
@ -438,10 +438,10 @@ namespace ccf
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
bp,
|
||||
consensus::snapshot_allocated,
|
||||
::consensus::snapshot_allocated,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
const auto [snapshot_span, generation_count] =
|
||||
ringbuffer::read_message<consensus::snapshot_allocated>(
|
||||
ringbuffer::read_message<::consensus::snapshot_allocated>(
|
||||
data, size);
|
||||
|
||||
node->write_snapshot(snapshot_span, generation_count);
|
||||
|
@ -462,7 +462,7 @@ namespace ccf
|
|||
// Then, execute some thread messages
|
||||
size_t thread_msg = 0;
|
||||
while (thread_msg < max_messages &&
|
||||
threading::ThreadMessaging::instance().run_one())
|
||||
::threading::ThreadMessaging::instance().run_one())
|
||||
{
|
||||
thread_msg++;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ namespace ccf
|
|||
uint64_t tid;
|
||||
};
|
||||
|
||||
static void init_thread_cb(std::unique_ptr<threading::Tmsg<Msg>> msg)
|
||||
static void init_thread_cb(std::unique_ptr<::threading::Tmsg<Msg>> msg)
|
||||
{
|
||||
LOG_DEBUG_FMT("First thread CB:{}", msg->data.tid);
|
||||
}
|
||||
|
@ -538,12 +538,12 @@ namespace ccf
|
|||
try
|
||||
#endif
|
||||
{
|
||||
auto msg = std::make_unique<threading::Tmsg<Msg>>(&init_thread_cb);
|
||||
msg->data.tid = threading::get_current_thread_id();
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
auto msg = std::make_unique<::threading::Tmsg<Msg>>(&init_thread_cb);
|
||||
msg->data.tid = ccf::threading::get_current_thread_id();
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
msg->data.tid, std::move(msg));
|
||||
|
||||
threading::ThreadMessaging::instance().run();
|
||||
::threading::ThreadMessaging::instance().run();
|
||||
crypto::openssl_sha256_shutdown();
|
||||
}
|
||||
#ifndef VIRTUAL_ENCLAVE
|
||||
|
|
|
@ -332,7 +332,7 @@ extern "C"
|
|||
// is safe for the first thread that calls enclave_run to re-use this
|
||||
// thread_id. That way they are both considered MAIN_THREAD_ID, even if
|
||||
// they are actually distinct std::threads.
|
||||
threading::reset_thread_id_generator();
|
||||
ccf::threading::reset_thread_id_generator();
|
||||
|
||||
return CreateNodeStatus::OK;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ extern "C"
|
|||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(create_lock);
|
||||
|
||||
tid = threading::get_current_thread_id();
|
||||
tid = ccf::threading::get_current_thread_id();
|
||||
num_pending_threads.fetch_sub(1);
|
||||
|
||||
LOG_INFO_FMT("Starting thread: {}", tid);
|
||||
|
@ -356,7 +356,7 @@ extern "C"
|
|||
|
||||
LOG_INFO_FMT("All threads are ready!");
|
||||
|
||||
if (tid == threading::MAIN_THREAD_ID)
|
||||
if (tid == ccf::threading::MAIN_THREAD_ID)
|
||||
{
|
||||
auto s = e.load()->run_main();
|
||||
while (num_complete_threads !=
|
||||
|
|
|
@ -61,19 +61,19 @@ namespace ccf
|
|||
ringbuffer::AbstractWriterFactory& writer_factory;
|
||||
ringbuffer::WriterPtr to_host = nullptr;
|
||||
std::shared_ptr<RPCMap> rpc_map;
|
||||
std::unordered_map<ListenInterfaceID, std::shared_ptr<tls::Cert>> certs;
|
||||
std::unordered_map<ListenInterfaceID, std::shared_ptr<::tls::Cert>> certs;
|
||||
std::shared_ptr<CustomProtocolSubsystem> custom_protocol_subsystem;
|
||||
|
||||
ccf::pal::Mutex lock;
|
||||
std::unordered_map<
|
||||
tls::ConnID,
|
||||
ccf::tls::ConnID,
|
||||
std::pair<ListenInterfaceID, std::shared_ptr<ccf::Session>>>
|
||||
sessions;
|
||||
size_t sessions_peak = 0;
|
||||
|
||||
// Negative sessions are reserved for those originating from
|
||||
// the enclave via create_client().
|
||||
std::atomic<tls::ConnID> next_client_session_id = -1;
|
||||
std::atomic<ccf::tls::ConnID> next_client_session_id = -1;
|
||||
|
||||
template <typename Base>
|
||||
class NoMoreSessionsImpl : public Base
|
||||
|
@ -101,7 +101,7 @@ namespace ccf
|
|||
}
|
||||
};
|
||||
|
||||
tls::ConnID get_next_client_id()
|
||||
ccf::tls::ConnID get_next_client_id()
|
||||
{
|
||||
auto id = next_client_session_id--;
|
||||
const auto initial = id;
|
||||
|
@ -141,7 +141,7 @@ namespace ccf
|
|||
|
||||
std::shared_ptr<ccf::Session> make_server_session(
|
||||
const std::string& app_protocol,
|
||||
tls::ConnID id,
|
||||
ccf::tls::ConnID id,
|
||||
const ListenInterfaceID& listen_interface_id,
|
||||
std::unique_ptr<tls::Context>&& ctx,
|
||||
const http::ParserConfiguration& parser_configuration)
|
||||
|
@ -307,7 +307,7 @@ namespace ccf
|
|||
// the caller's certificate in the relevant store table. The caller
|
||||
// certificate does not have to be signed by a known CA (nullptr) and
|
||||
// verification is not required here.
|
||||
auto cert = std::make_shared<tls::Cert>(
|
||||
auto cert = std::make_shared<::tls::Cert>(
|
||||
nullptr, cert_, pk, std::nullopt, /*auth_required ==*/false);
|
||||
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
@ -328,7 +328,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
void accept(
|
||||
tls::ConnID id,
|
||||
ccf::tls::ConnID id,
|
||||
const ListenInterfaceID& listen_interface_id,
|
||||
bool udp = false)
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ namespace ccf
|
|||
listen_interface_id);
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop, to_host, id, std::string("Session refused"));
|
||||
::tls::tls_stop, to_host, id, std::string("Session refused"));
|
||||
}
|
||||
else if (
|
||||
per_listen_interface.open_sessions >=
|
||||
|
@ -378,7 +378,7 @@ namespace ccf
|
|||
per_listen_interface.max_open_sessions_hard);
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop, to_host, id, std::string("Session refused"));
|
||||
::tls::tls_stop, to_host, id, std::string("Session refused"));
|
||||
}
|
||||
else if (
|
||||
per_listen_interface.open_sessions >=
|
||||
|
@ -392,7 +392,7 @@ namespace ccf
|
|||
listen_interface_id,
|
||||
per_listen_interface.max_open_sessions_soft);
|
||||
|
||||
auto ctx = std::make_unique<tls::Server>(certs[listen_interface_id]);
|
||||
auto ctx = std::make_unique<::tls::Server>(certs[listen_interface_id]);
|
||||
std::shared_ptr<Session> capped_session;
|
||||
if (per_listen_interface.app_protocol == "HTTP2")
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ namespace ccf
|
|||
}
|
||||
else
|
||||
{
|
||||
ctx = std::make_unique<tls::Server>(
|
||||
ctx = std::make_unique<::tls::Server>(
|
||||
certs[listen_interface_id],
|
||||
per_listen_interface.app_protocol == "HTTP2");
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ namespace ccf
|
|||
sessions_peak = std::max(sessions_peak, sessions.size());
|
||||
}
|
||||
|
||||
std::shared_ptr<Session> find_session(tls::ConnID id)
|
||||
std::shared_ptr<Session> find_session(ccf::tls::ConnID id)
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
||||
|
@ -509,7 +509,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
bool reply_async(
|
||||
tls::ConnID id,
|
||||
ccf::tls::ConnID id,
|
||||
bool terminate_after_send,
|
||||
std::vector<uint8_t>&& data) override
|
||||
{
|
||||
|
@ -532,7 +532,7 @@ namespace ccf
|
|||
return true;
|
||||
}
|
||||
|
||||
void remove_session(tls::ConnID id)
|
||||
void remove_session(ccf::tls::ConnID id)
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
LOG_DEBUG_FMT("Closing a session inside the enclave: {}", id);
|
||||
|
@ -549,11 +549,11 @@ namespace ccf
|
|||
}
|
||||
|
||||
std::shared_ptr<ClientSession> create_client(
|
||||
const std::shared_ptr<tls::Cert>& cert,
|
||||
const std::shared_ptr<::tls::Cert>& cert,
|
||||
const std::string& app_protocol = "HTTP1")
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
auto ctx = std::make_unique<tls::Client>(cert);
|
||||
auto ctx = std::make_unique<::tls::Client>(cert);
|
||||
auto id = get_next_client_id();
|
||||
|
||||
LOG_DEBUG_FMT("Creating a new client session inside the enclave: {}", id);
|
||||
|
@ -598,15 +598,15 @@ namespace ccf
|
|||
messaging::Dispatcher<ringbuffer::Message>& disp)
|
||||
{
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_start, [this](const uint8_t* data, size_t size) {
|
||||
disp, ::tls::tls_start, [this](const uint8_t* data, size_t size) {
|
||||
auto [new_tls_id, listen_interface_name] =
|
||||
ringbuffer::read_message<tls::tls_start>(data, size);
|
||||
ringbuffer::read_message<::tls::tls_start>(data, size);
|
||||
accept(new_tls_id, listen_interface_name);
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_inbound, [this](const uint8_t* data, size_t size) {
|
||||
auto id = serialized::peek<tls::ConnID>(data, size);
|
||||
disp, ::tls::tls_inbound, [this](const uint8_t* data, size_t size) {
|
||||
auto id = serialized::peek<ccf::tls::ConnID>(data, size);
|
||||
|
||||
auto search = sessions.find(id);
|
||||
if (search == sessions.end())
|
||||
|
@ -620,8 +620,8 @@ namespace ccf
|
|||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_close, [this](const uint8_t* data, size_t size) {
|
||||
auto [id] = ringbuffer::read_message<tls::tls_close>(data, size);
|
||||
disp, ::tls::tls_close, [this](const uint8_t* data, size_t size) {
|
||||
auto [id] = ringbuffer::read_message<::tls::tls_close>(data, size);
|
||||
remove_session(id);
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ccf
|
|||
ThreadedSession(int64_t thread_affinity)
|
||||
{
|
||||
execution_thread =
|
||||
threading::ThreadMessaging::instance().get_execution_thread(
|
||||
::threading::ThreadMessaging::instance().get_execution_thread(
|
||||
thread_affinity);
|
||||
}
|
||||
|
||||
|
@ -34,19 +34,19 @@ namespace ccf
|
|||
// that eventually invokes the virtual handle_incoming_data_thread()
|
||||
void handle_incoming_data(std::span<const uint8_t> data) override
|
||||
{
|
||||
auto [_, body] = ringbuffer::read_message<tls::tls_inbound>(data);
|
||||
auto [_, body] = ringbuffer::read_message<::tls::tls_inbound>(data);
|
||||
|
||||
auto msg = std::make_unique<threading::Tmsg<SendRecvMsg>>(
|
||||
auto msg = std::make_unique<::threading::Tmsg<SendRecvMsg>>(
|
||||
&handle_incoming_data_cb);
|
||||
msg->data.self = this->shared_from_this();
|
||||
msg->data.data.assign(body.data, body.data + body.size);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
execution_thread, std::move(msg));
|
||||
}
|
||||
|
||||
static void handle_incoming_data_cb(
|
||||
std::unique_ptr<threading::Tmsg<SendRecvMsg>> msg)
|
||||
std::unique_ptr<::threading::Tmsg<SendRecvMsg>> msg)
|
||||
{
|
||||
msg->data.self->handle_incoming_data_thread(std::move(msg->data.data));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the Apache 2.0 License.
|
||||
#include "ccf/ds/thread_ids.h"
|
||||
#include "ccf/threading/thread_ids.h"
|
||||
|
||||
namespace threading
|
||||
namespace ccf::threading
|
||||
{
|
||||
static std::atomic<ThreadID> next_thread_id = MAIN_THREAD_ID;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace ccf
|
|||
|
||||
protected:
|
||||
ringbuffer::WriterPtr to_host;
|
||||
tls::ConnID session_id;
|
||||
::tls::ConnID session_id;
|
||||
size_t execution_thread;
|
||||
|
||||
private:
|
||||
|
@ -80,13 +80,14 @@ namespace ccf
|
|||
status(handshake)
|
||||
{
|
||||
execution_thread =
|
||||
threading::ThreadMessaging::instance().get_execution_thread(session_id);
|
||||
::threading::ThreadMessaging::instance().get_execution_thread(
|
||||
session_id);
|
||||
ctx->set_bio(this, send_callback_openssl, recv_callback_openssl);
|
||||
}
|
||||
|
||||
virtual ~TLSSession()
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(tls::tls_closed, to_host, session_id);
|
||||
RINGBUFFER_WRITE_MESSAGE(::tls::tls_closed, to_host, session_id);
|
||||
}
|
||||
|
||||
SessionStatus get_status() const
|
||||
|
@ -177,7 +178,7 @@ namespace ccf
|
|||
case TLS_ERR_CONN_CLOSE_NOTIFY:
|
||||
{
|
||||
LOG_TRACE_FMT(
|
||||
"TLS {} close on read: {}", session_id, tls::error_string(r));
|
||||
"TLS {} close on read: {}", session_id, ::tls::error_string(r));
|
||||
|
||||
stop(closed);
|
||||
|
||||
|
@ -213,7 +214,7 @@ namespace ccf
|
|||
if (r < 0)
|
||||
{
|
||||
LOG_TRACE_FMT(
|
||||
"TLS {} error on read: {}", session_id, tls::error_string(r));
|
||||
"TLS {} error on read: {}", session_id, ::tls::error_string(r));
|
||||
stop(error);
|
||||
return 0;
|
||||
}
|
||||
|
@ -236,7 +237,7 @@ namespace ccf
|
|||
|
||||
void recv_buffered(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called recv_buffered from incorrect thread");
|
||||
}
|
||||
|
@ -252,12 +253,12 @@ namespace ccf
|
|||
void close()
|
||||
{
|
||||
status = closing;
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
auto msg = std::make_unique<threading::Tmsg<EmptyMsg>>(&close_cb);
|
||||
auto msg = std::make_unique<::threading::Tmsg<EmptyMsg>>(&close_cb);
|
||||
msg->data.self = this->shared_from_this();
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
execution_thread, std::move(msg));
|
||||
}
|
||||
else
|
||||
|
@ -267,14 +268,14 @@ namespace ccf
|
|||
}
|
||||
}
|
||||
|
||||
static void close_cb(std::unique_ptr<threading::Tmsg<EmptyMsg>> msg)
|
||||
static void close_cb(std::unique_ptr<::threading::Tmsg<EmptyMsg>> msg)
|
||||
{
|
||||
msg->data.self->close_thread();
|
||||
}
|
||||
|
||||
virtual void close_thread()
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called close_thread from incorrect thread");
|
||||
}
|
||||
|
@ -311,7 +312,9 @@ namespace ccf
|
|||
default:
|
||||
{
|
||||
LOG_TRACE_FMT(
|
||||
"TLS {} error on_close: {}", session_id, tls::error_string(r));
|
||||
"TLS {} error on_close: {}",
|
||||
session_id,
|
||||
::tls::error_string(r));
|
||||
stop(error);
|
||||
break;
|
||||
}
|
||||
|
@ -327,13 +330,14 @@ namespace ccf
|
|||
|
||||
void send_raw(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
auto msg = std::make_unique<threading::Tmsg<SendRecvMsg>>(&send_raw_cb);
|
||||
auto msg =
|
||||
std::make_unique<::threading::Tmsg<SendRecvMsg>>(&send_raw_cb);
|
||||
msg->data.self = this->shared_from_this();
|
||||
msg->data.data = std::vector<uint8_t>(data, data + size);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
execution_thread, std::move(msg));
|
||||
}
|
||||
else
|
||||
|
@ -344,7 +348,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
private:
|
||||
static void send_raw_cb(std::unique_ptr<threading::Tmsg<SendRecvMsg>> msg)
|
||||
static void send_raw_cb(std::unique_ptr<::threading::Tmsg<SendRecvMsg>> msg)
|
||||
{
|
||||
msg->data.self->send_raw_thread(
|
||||
msg->data.data.data(), msg->data.data.size());
|
||||
|
@ -352,7 +356,7 @@ namespace ccf
|
|||
|
||||
void send_raw_thread(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Called send_raw_thread from incorrect thread");
|
||||
|
@ -380,7 +384,7 @@ namespace ccf
|
|||
|
||||
void send_buffered(const std::vector<uint8_t>& data)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called send_buffered from incorrect thread");
|
||||
}
|
||||
|
@ -390,7 +394,7 @@ namespace ccf
|
|||
|
||||
void flush()
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called flush from incorrect thread");
|
||||
}
|
||||
|
@ -450,7 +454,7 @@ namespace ccf
|
|||
on_handshake_error(fmt::format(
|
||||
"TLS {} verify error on handshake: {}",
|
||||
session_id,
|
||||
tls::error_string(rc)));
|
||||
::tls::error_string(rc)));
|
||||
stop(authfail);
|
||||
break;
|
||||
}
|
||||
|
@ -460,7 +464,7 @@ namespace ccf
|
|||
LOG_TRACE_FMT(
|
||||
"TLS {} closed on handshake: {}",
|
||||
session_id,
|
||||
tls::error_string(rc));
|
||||
::tls::error_string(rc));
|
||||
stop(closed);
|
||||
break;
|
||||
}
|
||||
|
@ -472,7 +476,7 @@ namespace ccf
|
|||
"TLS {} invalid cert on handshake: {} [{}]",
|
||||
session_id,
|
||||
err,
|
||||
tls::error_string(rc)));
|
||||
::tls::error_string(rc)));
|
||||
stop(authfail);
|
||||
return;
|
||||
}
|
||||
|
@ -482,7 +486,7 @@ namespace ccf
|
|||
on_handshake_error(fmt::format(
|
||||
"TLS {} error on handshake: {}",
|
||||
session_id,
|
||||
tls::error_string(rc)));
|
||||
::tls::error_string(rc)));
|
||||
stop(error);
|
||||
break;
|
||||
}
|
||||
|
@ -526,14 +530,17 @@ namespace ccf
|
|||
case closed:
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop, to_host, session_id, std::string("Session closed"));
|
||||
::tls::tls_stop,
|
||||
to_host,
|
||||
session_id,
|
||||
std::string("Session closed"));
|
||||
break;
|
||||
}
|
||||
|
||||
case authfail:
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop,
|
||||
::tls::tls_stop,
|
||||
to_host,
|
||||
session_id,
|
||||
std::string("Authentication failed"));
|
||||
|
@ -541,7 +548,7 @@ namespace ccf
|
|||
case error:
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop, to_host, session_id, std::string("Error"));
|
||||
::tls::tls_stop, to_host, session_id, std::string("Error"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -555,7 +562,7 @@ namespace ccf
|
|||
{
|
||||
// Either write all of the data or none of it.
|
||||
auto wrote = RINGBUFFER_TRY_WRITE_MESSAGE(
|
||||
tls::tls_outbound,
|
||||
::tls::tls_outbound,
|
||||
to_host,
|
||||
session_id,
|
||||
serializer::ByteRange{buf, len});
|
||||
|
@ -568,7 +575,7 @@ namespace ccf
|
|||
|
||||
int handle_recv(uint8_t* buf, size_t len)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called handle_recv from incorrect thread");
|
||||
}
|
||||
|
|
|
@ -49,12 +49,13 @@ namespace ccf
|
|||
|
||||
const auto valid_from_unix_time =
|
||||
duration_cast<seconds>(
|
||||
ds::time_point_from_string(valid_from_timestring)
|
||||
::ds::time_point_from_string(valid_from_timestring)
|
||||
.time_since_epoch())
|
||||
.count();
|
||||
const auto valid_to_unix_time =
|
||||
duration_cast<seconds>(
|
||||
ds::time_point_from_string(valid_to_timestring).time_since_epoch())
|
||||
::ds::time_point_from_string(valid_to_timestring)
|
||||
.time_since_epoch())
|
||||
.count();
|
||||
|
||||
it = periods.insert(
|
||||
|
|
|
@ -70,10 +70,10 @@ namespace host
|
|||
Enclave enclave = {};
|
||||
|
||||
// Other
|
||||
ds::TimeString tick_interval = {"10ms"};
|
||||
ds::TimeString slow_io_logging_threshold = {"10ms"};
|
||||
ccf::ds::TimeString tick_interval = {"10ms"};
|
||||
ccf::ds::TimeString slow_io_logging_threshold = {"10ms"};
|
||||
std::optional<std::string> node_client_interface = std::nullopt;
|
||||
ds::TimeString client_connection_timeout = {"2000ms"};
|
||||
ccf::ds::TimeString client_connection_timeout = {"2000ms"};
|
||||
std::optional<std::string> node_data_json_file = std::nullopt;
|
||||
std::optional<std::string> service_data_json_file = std::nullopt;
|
||||
bool ignore_first_sigterm = false;
|
||||
|
@ -95,7 +95,7 @@ namespace host
|
|||
{
|
||||
std::string directory = "ledger";
|
||||
std::vector<std::string> read_only_directories = {};
|
||||
ds::SizeString chunk_size = {"5MB"};
|
||||
ccf::ds::SizeString chunk_size = {"5MB"};
|
||||
|
||||
bool operator==(const Ledger&) const = default;
|
||||
};
|
||||
|
@ -122,9 +122,9 @@ namespace host
|
|||
|
||||
struct Memory
|
||||
{
|
||||
ds::SizeString circuit_size = {"16MB"};
|
||||
ds::SizeString max_msg_size = {"64MB"};
|
||||
ds::SizeString max_fragment_size = {"256KB"};
|
||||
ccf::ds::SizeString circuit_size = {"16MB"};
|
||||
ccf::ds::SizeString max_msg_size = {"64MB"};
|
||||
ccf::ds::SizeString max_fragment_size = {"256KB"};
|
||||
|
||||
bool operator==(const Memory&) const = default;
|
||||
};
|
||||
|
@ -150,7 +150,7 @@ namespace host
|
|||
struct Join
|
||||
{
|
||||
ccf::NodeInfoNetwork::NetAddress target_rpc_address;
|
||||
ds::TimeString retry_timeout = {"1000ms"};
|
||||
ccf::ds::TimeString retry_timeout = {"1000ms"};
|
||||
bool follow_redirect = true;
|
||||
|
||||
bool operator==(const Join&) const = default;
|
||||
|
|
|
@ -1501,12 +1501,12 @@ namespace asynchost
|
|||
size_t from_idx,
|
||||
size_t to_idx,
|
||||
std::optional<LedgerReadResult>&& read_result,
|
||||
consensus::LedgerRequestPurpose purpose)
|
||||
::consensus::LedgerRequestPurpose purpose)
|
||||
{
|
||||
if (read_result.has_value())
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_entry_range,
|
||||
::consensus::ledger_entry_range,
|
||||
to_enclave,
|
||||
from_idx,
|
||||
read_result->end_idx,
|
||||
|
@ -1516,7 +1516,7 @@ namespace asynchost
|
|||
else
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_no_entry_range,
|
||||
::consensus::ledger_no_entry_range,
|
||||
to_enclave,
|
||||
from_idx,
|
||||
to_idx,
|
||||
|
@ -1528,16 +1528,18 @@ namespace asynchost
|
|||
messaging::Dispatcher<ringbuffer::Message>& disp)
|
||||
{
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, consensus::ledger_init, [this](const uint8_t* data, size_t size) {
|
||||
auto idx = serialized::read<consensus::Index>(data, size);
|
||||
disp,
|
||||
::consensus::ledger_init,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto idx = serialized::read<::consensus::Index>(data, size);
|
||||
auto recovery_start_index =
|
||||
serialized::read<consensus::Index>(data, size);
|
||||
serialized::read<::consensus::Index>(data, size);
|
||||
init(idx, recovery_start_index);
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::ledger_append,
|
||||
::consensus::ledger_append,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto committable = serialized::read<bool>(data, size);
|
||||
write_entry(data, size, committable);
|
||||
|
@ -1545,9 +1547,9 @@ namespace asynchost
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::ledger_truncate,
|
||||
::consensus::ledger_truncate,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto idx = serialized::read<consensus::Index>(data, size);
|
||||
auto idx = serialized::read<::consensus::Index>(data, size);
|
||||
auto recovery_mode = serialized::read<bool>(data, size);
|
||||
truncate(idx);
|
||||
if (recovery_mode)
|
||||
|
@ -1558,23 +1560,23 @@ namespace asynchost
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::ledger_commit,
|
||||
::consensus::ledger_commit,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto idx = serialized::read<consensus::Index>(data, size);
|
||||
auto idx = serialized::read<::consensus::Index>(data, size);
|
||||
commit(idx);
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, consensus::ledger_open, [this](const uint8_t*, size_t) {
|
||||
disp, ::consensus::ledger_open, [this](const uint8_t*, size_t) {
|
||||
complete_recovery();
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::ledger_get_range,
|
||||
::consensus::ledger_get_range,
|
||||
[&](const uint8_t* data, size_t size) {
|
||||
auto [from_idx, to_idx, purpose] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
|
||||
// Ledger entries response has metadata so cap total entries size
|
||||
// accordingly
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache 2.0 License.
|
||||
|
||||
#include "ccf/ds/logger.h"
|
||||
#include "ccf/ds/unit_strings.h"
|
||||
#include "ccf/pal/attestation.h"
|
||||
#include "ccf/pal/platform.h"
|
||||
#include "ccf/version.h"
|
||||
|
@ -90,7 +91,7 @@ int main(int argc, char** argv)
|
|||
app.add_option(
|
||||
"-c,--config", config_file_path, "Path to JSON configuration file");
|
||||
|
||||
ds::TimeString config_timeout = {"0s"};
|
||||
ccf::ds::TimeString config_timeout = {"0s"};
|
||||
app.add_option(
|
||||
"--config-timeout",
|
||||
config_timeout,
|
||||
|
|
|
@ -371,7 +371,7 @@ namespace asynchost
|
|||
{
|
||||
// Parse the indices to be sent to the recipient.
|
||||
const auto& ae =
|
||||
serialized::overlay<consensus::AppendEntriesIndex>(data, size);
|
||||
serialized::overlay<::consensus::AppendEntriesIndex>(data, size);
|
||||
|
||||
// Find the total frame size, and write it along with the header.
|
||||
uint32_t frame = (uint32_t)size_to_send;
|
||||
|
|
|
@ -50,10 +50,10 @@ namespace asynchost
|
|||
class ConnIDGenerator
|
||||
{
|
||||
public:
|
||||
/// This is the same as tls::ConnID and quic::ConnID
|
||||
/// This is the same as ccf::tls::ConnID and quic::ConnID
|
||||
using ConnID = int64_t;
|
||||
static_assert(std::is_same<tls::ConnID, quic::ConnID>());
|
||||
static_assert(std::is_same<tls::ConnID, ConnID>());
|
||||
static_assert(std::is_same<::tls::ConnID, quic::ConnID>());
|
||||
static_assert(std::is_same<::tls::ConnID, ConnID>());
|
||||
|
||||
ConnIDGenerator() : next_id(1) {}
|
||||
|
||||
|
@ -121,7 +121,7 @@ namespace asynchost
|
|||
LOG_DEBUG_FMT("rpc read {}: {}", id, len);
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_inbound,
|
||||
::tls::tls_inbound,
|
||||
parent.to_enclave,
|
||||
id,
|
||||
serializer::ByteRange{data, len});
|
||||
|
@ -139,7 +139,7 @@ namespace asynchost
|
|||
{
|
||||
if constexpr (isTCP<ConnType>())
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(tls::tls_close, parent.to_enclave, id);
|
||||
RINGBUFFER_WRITE_MESSAGE(::tls::tls_close, parent.to_enclave, id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -185,7 +185,7 @@ namespace asynchost
|
|||
if constexpr (isTCP<ConnType>())
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_start, parent.to_enclave, peer_id, interface_name);
|
||||
::tls::tls_start, parent.to_enclave, peer_id, interface_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ namespace asynchost
|
|||
// Invalidating the TCP socket will result in the handle being closed. No
|
||||
// more messages will be read from or written to the TCP socket.
|
||||
sockets[id] = nullptr;
|
||||
RINGBUFFER_WRITE_MESSAGE(tls::tls_close, to_enclave, id);
|
||||
RINGBUFFER_WRITE_MESSAGE(::tls::tls_close, to_enclave, id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -348,9 +348,9 @@ namespace asynchost
|
|||
messaging::Dispatcher<ringbuffer::Message>& disp)
|
||||
{
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_outbound, [this](const uint8_t* data, size_t size) {
|
||||
disp, ::tls::tls_outbound, [this](const uint8_t* data, size_t size) {
|
||||
auto [id, body] =
|
||||
ringbuffer::read_message<tls::tls_outbound>(data, size);
|
||||
ringbuffer::read_message<::tls::tls_outbound>(data, size);
|
||||
|
||||
ConnID connect_id = (ConnID)id;
|
||||
LOG_DEBUG_FMT("rpc write from enclave {}: {}", connect_id, body.size);
|
||||
|
@ -359,9 +359,9 @@ namespace asynchost
|
|||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_connect, [this](const uint8_t* data, size_t size) {
|
||||
disp, ::tls::tls_connect, [this](const uint8_t* data, size_t size) {
|
||||
auto [id, host, port] =
|
||||
ringbuffer::read_message<tls::tls_connect>(data, size);
|
||||
ringbuffer::read_message<::tls::tls_connect>(data, size);
|
||||
|
||||
LOG_DEBUG_FMT("rpc connect request from enclave {}", id);
|
||||
|
||||
|
@ -377,16 +377,17 @@ namespace asynchost
|
|||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_stop, [this](const uint8_t* data, size_t size) {
|
||||
auto [id, msg] = ringbuffer::read_message<tls::tls_stop>(data, size);
|
||||
disp, ::tls::tls_stop, [this](const uint8_t* data, size_t size) {
|
||||
auto [id, msg] =
|
||||
ringbuffer::read_message<::tls::tls_stop>(data, size);
|
||||
|
||||
LOG_DEBUG_FMT("rpc stop from enclave {}, {}", id, msg);
|
||||
stop(id);
|
||||
});
|
||||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp, tls::tls_closed, [this](const uint8_t* data, size_t size) {
|
||||
auto [id] = ringbuffer::read_message<tls::tls_closed>(data, size);
|
||||
disp, ::tls::tls_closed, [this](const uint8_t* data, size_t size) {
|
||||
auto [id] = ringbuffer::read_message<::tls::tls_closed>(data, size);
|
||||
|
||||
LOG_DEBUG_FMT("rpc closed from enclave {}", id);
|
||||
close(id);
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace asynchost
|
|||
|
||||
struct PendingSnapshot
|
||||
{
|
||||
consensus::Index evidence_idx;
|
||||
::consensus::Index evidence_idx;
|
||||
std::shared_ptr<std::vector<uint8_t>> snapshot;
|
||||
};
|
||||
std::map<size_t, PendingSnapshot> pending_snapshots;
|
||||
|
@ -220,8 +220,8 @@ namespace asynchost
|
|||
}
|
||||
|
||||
std::shared_ptr<std::vector<uint8_t>> add_pending_snapshot(
|
||||
consensus::Index idx,
|
||||
consensus::Index evidence_idx,
|
||||
::consensus::Index idx,
|
||||
::consensus::Index evidence_idx,
|
||||
size_t requested_size)
|
||||
{
|
||||
auto snapshot = std::make_shared<std::vector<uint8_t>>(requested_size);
|
||||
|
@ -234,7 +234,7 @@ namespace asynchost
|
|||
}
|
||||
|
||||
void commit_snapshot(
|
||||
consensus::Index snapshot_idx,
|
||||
::consensus::Index snapshot_idx,
|
||||
const uint8_t* receipt_data,
|
||||
size_t receipt_size)
|
||||
{
|
||||
|
@ -338,10 +338,10 @@ namespace asynchost
|
|||
{
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::snapshot_allocate,
|
||||
::consensus::snapshot_allocate,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto idx = serialized::read<consensus::Index>(data, size);
|
||||
auto evidence_idx = serialized::read<consensus::Index>(data, size);
|
||||
auto idx = serialized::read<::consensus::Index>(data, size);
|
||||
auto evidence_idx = serialized::read<::consensus::Index>(data, size);
|
||||
auto requested_size = serialized::read<size_t>(data, size);
|
||||
auto generation_count = serialized::read<uint32_t>(data, size);
|
||||
|
||||
|
@ -349,7 +349,7 @@ namespace asynchost
|
|||
add_pending_snapshot(idx, evidence_idx, requested_size);
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::snapshot_allocated,
|
||||
::consensus::snapshot_allocated,
|
||||
to_enclave,
|
||||
std::span<uint8_t>{snapshot->data(), snapshot->size()},
|
||||
generation_count);
|
||||
|
@ -357,9 +357,9 @@ namespace asynchost
|
|||
|
||||
DISPATCHER_SET_MESSAGE_HANDLER(
|
||||
disp,
|
||||
consensus::snapshot_commit,
|
||||
::consensus::snapshot_commit,
|
||||
[this](const uint8_t* data, size_t size) {
|
||||
auto snapshot_idx = serialized::read<consensus::Index>(data, size);
|
||||
auto snapshot_idx = serialized::read<::consensus::Index>(data, size);
|
||||
commit_snapshot(snapshot_idx, data, size);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace http
|
|||
protected:
|
||||
std::shared_ptr<ccf::TLSSession> tls_io;
|
||||
std::shared_ptr<ErrorReporter> error_reporter;
|
||||
tls::ConnID session_id;
|
||||
::tls::ConnID session_id;
|
||||
|
||||
HTTP2Session(
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx,
|
||||
std::unique_ptr<ccf::tls::Context> ctx,
|
||||
const std::shared_ptr<ErrorReporter>& error_reporter = nullptr) :
|
||||
ccf::ThreadedSession(session_id_),
|
||||
tls_io(std::make_shared<ccf::TLSSession>(
|
||||
|
@ -312,7 +312,7 @@ namespace http
|
|||
int64_t session_id_,
|
||||
const ccf::ListenInterfaceID& interface_id,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx,
|
||||
std::unique_ptr<ccf::tls::Context> ctx,
|
||||
const http::ParserConfiguration& configuration,
|
||||
const std::shared_ptr<ErrorReporter>& error_reporter,
|
||||
http::ResponderLookup& responder_lookup_) :
|
||||
|
@ -519,7 +519,7 @@ namespace http
|
|||
HTTP2ClientSession(
|
||||
int64_t session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx) :
|
||||
std::unique_ptr<ccf::tls::Context> ctx) :
|
||||
HTTP2Session(session_id_, writer_factory, std::move(ctx)),
|
||||
ccf::ClientSession(session_id_, writer_factory),
|
||||
client_parser(*this)
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace http
|
|||
{
|
||||
header_typed = header.get<JwtHeader>();
|
||||
}
|
||||
catch (const JsonParseError& e)
|
||||
catch (const ccf::JsonParseError& e)
|
||||
{
|
||||
error_reason =
|
||||
fmt::format("JWT header does not follow schema: {}", e.describe());
|
||||
|
@ -139,7 +139,7 @@ namespace http
|
|||
{
|
||||
payload_typed = payload.get<JwtPayload>();
|
||||
}
|
||||
catch (const JsonParseError& e)
|
||||
catch (const ccf::JsonParseError& e)
|
||||
{
|
||||
error_reason = fmt::format(
|
||||
"JWT payload is missing required field: {}", e.describe());
|
||||
|
|
|
@ -50,8 +50,8 @@ namespace http
|
|||
char const c = *src++;
|
||||
if (c == '%' && (src + 1) < end && isxdigit(src[0]) && isxdigit(src[1]))
|
||||
{
|
||||
const auto a = ds::hex_char_to_int(*src++);
|
||||
const auto b = ds::hex_char_to_int(*src++);
|
||||
const auto a = ccf::ds::hex_char_to_int(*src++);
|
||||
const auto b = ccf::ds::hex_char_to_int(*src++);
|
||||
*dst++ = (a << 4) | b;
|
||||
}
|
||||
else if (c == '+')
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace http
|
|||
protected:
|
||||
std::shared_ptr<ccf::TLSSession> tls_io;
|
||||
std::shared_ptr<ErrorReporter> error_reporter;
|
||||
tls::ConnID session_id;
|
||||
::tls::ConnID session_id;
|
||||
|
||||
HTTPSession(
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx,
|
||||
std::unique_ptr<ccf::tls::Context> ctx,
|
||||
const std::shared_ptr<ErrorReporter>& error_reporter = nullptr) :
|
||||
ccf::ThreadedSession(session_id_),
|
||||
tls_io(std::make_shared<ccf::TLSSession>(
|
||||
|
@ -99,10 +99,10 @@ namespace http
|
|||
public:
|
||||
HTTPServerSession(
|
||||
std::shared_ptr<ccf::RPCMap> rpc_map,
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
const ccf::ListenInterfaceID& interface_id,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx,
|
||||
std::unique_ptr<ccf::tls::Context> ctx,
|
||||
const http::ParserConfiguration& configuration,
|
||||
const std::shared_ptr<ErrorReporter>& error_reporter = nullptr) :
|
||||
HTTPSession(session_id_, writer_factory, std::move(ctx), error_reporter),
|
||||
|
@ -321,9 +321,9 @@ namespace http
|
|||
|
||||
public:
|
||||
HTTPClientSession(
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory,
|
||||
std::unique_ptr<tls::Context> ctx) :
|
||||
std::unique_ptr<ccf::tls::Context> ctx) :
|
||||
HTTPSession(session_id_, writer_factory, std::move(ctx)),
|
||||
ClientSession(session_id_, writer_factory),
|
||||
response_parser(*this)
|
||||
|
@ -394,13 +394,13 @@ namespace http
|
|||
{
|
||||
protected:
|
||||
std::shared_ptr<ErrorReporter> error_reporter;
|
||||
tls::ConnID session_id;
|
||||
::tls::ConnID session_id;
|
||||
ringbuffer::AbstractWriterFactory& writer_factory;
|
||||
ringbuffer::WriterPtr to_host;
|
||||
size_t execution_thread;
|
||||
|
||||
UnencryptedHTTPSession(
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory_,
|
||||
const std::shared_ptr<ErrorReporter>& error_reporter = nullptr) :
|
||||
ccf::ThreadedSession(session_id_),
|
||||
|
@ -419,14 +419,14 @@ namespace http
|
|||
|
||||
void send_data(std::span<const uint8_t> data) override
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::logic_error(
|
||||
"Called UnencryptedHTTPSession::send_data "
|
||||
"from wrong thread");
|
||||
}
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_outbound,
|
||||
::tls::tls_outbound,
|
||||
to_host,
|
||||
session_id,
|
||||
serializer::ByteRange{data.data(), data.size()});
|
||||
|
@ -434,14 +434,14 @@ namespace http
|
|||
|
||||
void close_session() override
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::logic_error(
|
||||
"Called UnencryptedHTTPSession::close_session "
|
||||
"from wrong thread");
|
||||
}
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
tls::tls_stop, to_host, session_id, std::string("Session closed"));
|
||||
::tls::tls_stop, to_host, session_id, std::string("Session closed"));
|
||||
}
|
||||
|
||||
void handle_incoming_data_thread(std::vector<uint8_t>&& data) override
|
||||
|
@ -459,7 +459,7 @@ namespace http
|
|||
|
||||
public:
|
||||
UnencryptedHTTPClientSession(
|
||||
tls::ConnID session_id_,
|
||||
::tls::ConnID session_id_,
|
||||
ringbuffer::AbstractWriterFactory& writer_factory) :
|
||||
UnencryptedHTTPSession(session_id_, writer_factory),
|
||||
ClientSession(session_id_, writer_factory),
|
||||
|
|
|
@ -16,14 +16,14 @@ namespace http
|
|||
using ByStream =
|
||||
std::unordered_map<http2::StreamId, std::shared_ptr<HTTPResponder>>;
|
||||
|
||||
std::unordered_map<tls::ConnID, ByStream> all_responders;
|
||||
std::unordered_map<::tls::ConnID, ByStream> all_responders;
|
||||
|
||||
// Responder lookup is shared by all HTTP sessions
|
||||
ccf::pal::Mutex lock;
|
||||
|
||||
public:
|
||||
std::shared_ptr<HTTPResponder> lookup_responder(
|
||||
tls::ConnID session_id, http2::StreamId stream_id)
|
||||
::tls::ConnID session_id, http2::StreamId stream_id)
|
||||
{
|
||||
std::unique_lock<ccf::pal::Mutex> guard(lock);
|
||||
auto conn_it = all_responders.find(session_id);
|
||||
|
@ -41,7 +41,7 @@ namespace http
|
|||
}
|
||||
|
||||
void add_responder(
|
||||
tls::ConnID session_id,
|
||||
::tls::ConnID session_id,
|
||||
http2::StreamId stream_id,
|
||||
std::shared_ptr<HTTPResponder> responder)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace http
|
|||
all_responders[session_id][stream_id] = responder;
|
||||
}
|
||||
|
||||
void cleanup_responders(tls::ConnID session_id)
|
||||
void cleanup_responders(::tls::ConnID session_id)
|
||||
{
|
||||
std::unique_lock<ccf::pal::Mutex> guard(lock);
|
||||
all_responders.erase(session_id);
|
||||
|
|
|
@ -282,7 +282,7 @@ aft::LedgerStubProxy* add_raft_consensus(
|
|||
using AllCommittableRaftConsensus = AllCommittableWrapper<TRaft>;
|
||||
using ms = std::chrono::milliseconds;
|
||||
const std::string node_id = "Node 0";
|
||||
const consensus::Configuration settings{{"20ms"}, {"100ms"}};
|
||||
const ccf::consensus::Configuration settings{{"20ms"}, {"100ms"}};
|
||||
auto consensus = std::make_shared<AllCommittableRaftConsensus>(
|
||||
settings,
|
||||
std::make_unique<aft::Adaptor<kv::Store>>(kv_store),
|
||||
|
@ -382,11 +382,11 @@ TEST_CASE_TEMPLATE(
|
|||
|
||||
const uint8_t* data = write.contents.data();
|
||||
size_t size = write.contents.size();
|
||||
REQUIRE(write.m == consensus::ledger_get_range);
|
||||
REQUIRE(write.m == ::consensus::ledger_get_range);
|
||||
auto [from_seqno, to_seqno, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
|
||||
std::vector<uint8_t> combined;
|
||||
for (auto seqno = from_seqno; seqno <= to_seqno; ++seqno)
|
||||
|
@ -590,11 +590,12 @@ TEST_CASE(
|
|||
|
||||
const uint8_t* data = write.contents.data();
|
||||
size_t size = write.contents.size();
|
||||
REQUIRE(write.m == consensus::ledger_get_range);
|
||||
REQUIRE(write.m == ::consensus::ledger_get_range);
|
||||
auto [from_seqno, to_seqno, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(
|
||||
purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
|
||||
std::vector<uint8_t> combined;
|
||||
for (auto seqno = from_seqno; seqno <= to_seqno; ++seqno)
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace ccf::js::extensions
|
|||
|
||||
try
|
||||
{
|
||||
tls::CA ca(pem.value());
|
||||
::tls::CA ca(pem.value());
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,10 @@ namespace kv
|
|||
|
||||
auto commit_nonce = e->get_commit_nonce({pimpl->commit_view, version});
|
||||
commit_evidence = fmt::format(
|
||||
"ce:{}.{}:{}", pimpl->commit_view, version, ds::to_hex(commit_nonce));
|
||||
"ce:{}.{}:{}",
|
||||
pimpl->commit_view,
|
||||
version,
|
||||
ccf::ds::to_hex(commit_nonce));
|
||||
LOG_TRACE_FMT("Commit evidence: {}", commit_evidence);
|
||||
crypto::Sha256Hash tx_commit_evidence_digest(commit_evidence);
|
||||
commit_evidence_digest = tx_commit_evidence_digest;
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace ACME
|
|||
crypto::make_key_pair();
|
||||
LOG_DEBUG_FMT(
|
||||
"ACME: new account public key: {}",
|
||||
ds::to_hex(account_key_pair->public_key_der()));
|
||||
ccf::ds::to_hex(account_key_pair->public_key_der()));
|
||||
}
|
||||
|
||||
bool has_active_orders() const
|
||||
|
|
|
@ -164,8 +164,8 @@ namespace ccf
|
|||
bool(http_status status, http::HeaderMap&&, std::vector<uint8_t>&&)>
|
||||
callback) override
|
||||
{
|
||||
auto ca = std::make_shared<tls::CA>(config.ca_certs, true);
|
||||
auto ca_cert = std::make_shared<tls::Cert>(ca);
|
||||
auto ca = std::make_shared<::tls::CA>(config.ca_certs, true);
|
||||
auto ca_cert = std::make_shared<::tls::Cert>(ca);
|
||||
auto client = rpc_sessions->create_client(ca_cert);
|
||||
|
||||
client->connect(
|
||||
|
@ -203,7 +203,7 @@ namespace ccf
|
|||
throw std::runtime_error("No ACME challenge handler");
|
||||
}
|
||||
|
||||
using namespace threading;
|
||||
using namespace ::threading;
|
||||
|
||||
challenge_handler->token_responses[token] = response;
|
||||
|
||||
|
|
|
@ -194,8 +194,8 @@ namespace ccf
|
|||
NodeId peer_id;
|
||||
|
||||
// Used for key exchange
|
||||
tls::KeyExchangeContext kex_ctx;
|
||||
ds::StateMachine<ChannelStatus> status;
|
||||
::tls::KeyExchangeContext kex_ctx;
|
||||
::ds::StateMachine<ChannelStatus> status;
|
||||
std::chrono::microseconds last_initiation_time;
|
||||
static constexpr size_t salt_len = 32;
|
||||
static constexpr size_t shared_key_size = 32;
|
||||
|
|
|
@ -503,11 +503,11 @@ namespace ccf::historical
|
|||
LOG_TRACE_FMT("fetch_entries_range({}, {})", from, to);
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_get_range,
|
||||
::consensus::ledger_get_range,
|
||||
to_host,
|
||||
static_cast<consensus::Index>(from),
|
||||
static_cast<consensus::Index>(to),
|
||||
consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
static_cast<::consensus::Index>(from),
|
||||
static_cast<::consensus::Index>(to),
|
||||
::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
}
|
||||
|
||||
std::optional<ccf::SeqNo> fetch_supporting_secret_if_needed(
|
||||
|
|
|
@ -493,8 +493,8 @@ namespace ccf
|
|||
|
||||
crypto::KeyPair& kp;
|
||||
|
||||
std::optional<threading::TaskQueue::TimerEntry> emit_signature_timer_entry =
|
||||
std::nullopt;
|
||||
std::optional<::threading::TaskQueue::TimerEntry>
|
||||
emit_signature_timer_entry = std::nullopt;
|
||||
size_t sig_tx_interval;
|
||||
size_t sig_ms_interval;
|
||||
|
||||
|
@ -532,8 +532,8 @@ namespace ccf
|
|||
HashedTxHistory<T>* self;
|
||||
};
|
||||
|
||||
auto emit_sig_msg = std::make_unique<threading::Tmsg<EmitSigMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<EmitSigMsg>> msg) {
|
||||
auto emit_sig_msg = std::make_unique<::threading::Tmsg<EmitSigMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<EmitSigMsg>> msg) {
|
||||
auto self = msg->data.self;
|
||||
|
||||
std::unique_lock<ccf::pal::Mutex> mguard(
|
||||
|
@ -576,13 +576,13 @@ namespace ccf
|
|||
}
|
||||
|
||||
self->emit_signature_timer_entry =
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), std::chrono::milliseconds(self->sig_ms_interval));
|
||||
},
|
||||
this);
|
||||
|
||||
emit_signature_timer_entry =
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(emit_sig_msg), std::chrono::milliseconds(sig_ms_interval));
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ namespace ccf
|
|||
{
|
||||
if (emit_signature_timer_entry.has_value())
|
||||
{
|
||||
threading::ThreadMessaging::instance().cancel_timer_task(
|
||||
::threading::ThreadMessaging::instance().cancel_timer_task(
|
||||
*emit_signature_timer_entry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace ccf
|
|||
|
||||
void start()
|
||||
{
|
||||
auto refresh_msg = std::make_unique<threading::Tmsg<RefreshTimeMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<RefreshTimeMsg>> msg) {
|
||||
auto refresh_msg = std::make_unique<::threading::Tmsg<RefreshTimeMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<RefreshTimeMsg>> msg) {
|
||||
if (!msg->data.self.consensus->can_replicate())
|
||||
{
|
||||
LOG_DEBUG_FMT(
|
||||
|
@ -68,7 +68,7 @@ namespace ccf
|
|||
"JWT key auto-refresh: Scheduling in {}s",
|
||||
msg->data.self.refresh_interval_s);
|
||||
auto delay = std::chrono::seconds(msg->data.self.refresh_interval_s);
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), delay);
|
||||
},
|
||||
*this);
|
||||
|
@ -76,14 +76,14 @@ namespace ccf
|
|||
LOG_DEBUG_FMT(
|
||||
"JWT key auto-refresh: Scheduling in {}s", refresh_interval_s);
|
||||
auto delay = std::chrono::seconds(refresh_interval_s);
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(refresh_msg), delay);
|
||||
}
|
||||
|
||||
void schedule_once()
|
||||
{
|
||||
auto refresh_msg = std::make_unique<threading::Tmsg<RefreshTimeMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<RefreshTimeMsg>> msg) {
|
||||
auto refresh_msg = std::make_unique<::threading::Tmsg<RefreshTimeMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<RefreshTimeMsg>> msg) {
|
||||
if (!msg->data.self.consensus->can_replicate())
|
||||
{
|
||||
LOG_DEBUG_FMT(
|
||||
|
@ -98,7 +98,7 @@ namespace ccf
|
|||
|
||||
LOG_DEBUG_FMT("JWT key one-off refresh: Scheduling without delay");
|
||||
auto delay = std::chrono::seconds(0);
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(refresh_msg), delay);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace ccf
|
|||
|
||||
void handle_jwt_metadata_response(
|
||||
const std::string& issuer,
|
||||
std::shared_ptr<tls::CA> ca,
|
||||
std::shared_ptr<::tls::CA> ca,
|
||||
http_status status,
|
||||
std::vector<uint8_t>&& data)
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ namespace ccf
|
|||
}
|
||||
auto jwks_url_port = !jwks_url.port.empty() ? jwks_url.port : "443";
|
||||
|
||||
auto ca_cert = std::make_shared<tls::Cert>(
|
||||
auto ca_cert = std::make_shared<::tls::Cert>(
|
||||
ca, std::nullopt, std::nullopt, jwks_url.host);
|
||||
|
||||
std::optional<std::string> issuer_constraint{std::nullopt};
|
||||
|
@ -321,8 +321,8 @@ namespace ccf
|
|||
auto metadata_url_port =
|
||||
!metadata_url.port.empty() ? metadata_url.port : "443";
|
||||
|
||||
auto ca = std::make_shared<tls::CA>(ca_cert_bundle_pem.value());
|
||||
auto ca_cert = std::make_shared<tls::Cert>(
|
||||
auto ca = std::make_shared<::tls::CA>(ca_cert_bundle_pem.value());
|
||||
auto ca_cert = std::make_shared<::tls::Cert>(
|
||||
ca, std::nullopt, std::nullopt, metadata_url.host);
|
||||
|
||||
LOG_DEBUG_FMT(
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
namespace ccf
|
||||
{
|
||||
using RaftType = aft::Aft<consensus::LedgerEnclave>;
|
||||
using RaftType = aft::Aft<::consensus::LedgerEnclave>;
|
||||
|
||||
struct NodeCreateInfo
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace ccf
|
|||
//
|
||||
// this node's core state
|
||||
//
|
||||
ds::StateMachine<NodeStartupState> sm;
|
||||
::ds::StateMachine<NodeStartupState> sm;
|
||||
pal::Mutex lock;
|
||||
StartType start_type;
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace ccf
|
|||
//
|
||||
ringbuffer::AbstractWriterFactory& writer_factory;
|
||||
ringbuffer::WriterPtr to_host;
|
||||
consensus::Configuration consensus_config;
|
||||
ccf::consensus::Configuration consensus_config;
|
||||
size_t sig_tx_interval;
|
||||
size_t sig_ms_interval;
|
||||
|
||||
|
@ -146,10 +146,10 @@ namespace ccf
|
|||
kv::Version recovery_v;
|
||||
crypto::Sha256Hash recovery_root;
|
||||
std::vector<kv::Version> view_history;
|
||||
consensus::Index last_recovered_signed_idx = 0;
|
||||
::consensus::Index last_recovered_signed_idx = 0;
|
||||
RecoveredEncryptedLedgerSecrets recovered_encrypted_ledger_secrets = {};
|
||||
LedgerSecretsMap recovered_ledger_secrets = {};
|
||||
consensus::Index last_recovered_idx = 0;
|
||||
::consensus::Index last_recovered_idx = 0;
|
||||
static const size_t recovery_batch_size = 100;
|
||||
|
||||
//
|
||||
|
@ -252,7 +252,7 @@ namespace ccf
|
|||
// funcs in state "uninitialized"
|
||||
//
|
||||
void initialize(
|
||||
const consensus::Configuration& consensus_config_,
|
||||
const ccf::consensus::Configuration& consensus_config_,
|
||||
std::shared_ptr<RPCMap> rpc_map_,
|
||||
std::shared_ptr<AbstractRPCResponder> rpc_sessions_,
|
||||
std::shared_ptr<indexing::Indexer> indexer_,
|
||||
|
@ -560,10 +560,10 @@ namespace ccf
|
|||
{
|
||||
sm.expect(NodeStartupState::pending);
|
||||
|
||||
auto network_ca = std::make_shared<tls::CA>(std::string(
|
||||
auto network_ca = std::make_shared<::tls::CA>(std::string(
|
||||
config.join.service_cert.begin(), config.join.service_cert.end()));
|
||||
|
||||
auto join_client_cert = std::make_unique<tls::Cert>(
|
||||
auto join_client_cert = std::make_unique<::tls::Cert>(
|
||||
network_ca,
|
||||
self_signed_node_cert,
|
||||
node_sign_kp->private_key_pem(),
|
||||
|
@ -797,8 +797,8 @@ namespace ccf
|
|||
{
|
||||
initiate_join_unsafe();
|
||||
|
||||
auto timer_msg = std::make_unique<threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<NodeStateMsg>> msg) {
|
||||
auto timer_msg = std::make_unique<::threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<NodeStateMsg>> msg) {
|
||||
std::lock_guard<pal::Mutex> guard(msg->data.self.lock);
|
||||
if (msg->data.self.sm.check(NodeStartupState::pending))
|
||||
{
|
||||
|
@ -806,13 +806,13 @@ namespace ccf
|
|||
auto delay = std::chrono::milliseconds(
|
||||
msg->data.self.config.join.retry_timeout);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), delay);
|
||||
}
|
||||
},
|
||||
*this);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(timer_msg), config.join.retry_timeout);
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ namespace ccf
|
|||
|
||||
while (size > 0)
|
||||
{
|
||||
auto entry = consensus::LedgerEnclave::get_entry(data, size);
|
||||
auto entry = ::consensus::LedgerEnclave::get_entry(data, size);
|
||||
|
||||
LOG_INFO_FMT("Deserialising public ledger entry [{}]", entry.size());
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ namespace ccf
|
|||
|
||||
while (size > 0)
|
||||
{
|
||||
auto entry = consensus::LedgerEnclave::get_entry(data, size);
|
||||
auto entry = ::consensus::LedgerEnclave::get_entry(data, size);
|
||||
|
||||
LOG_INFO_FMT("Deserialising private ledger entry [{}]", entry.size());
|
||||
|
||||
|
@ -1962,8 +1962,8 @@ namespace ccf
|
|||
{
|
||||
// Service creation transaction is asynchronous to avoid deadlocks
|
||||
// (e.g. https://github.com/microsoft/CCF/issues/3788)
|
||||
auto msg = std::make_unique<threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<NodeStateMsg>> msg) {
|
||||
auto msg = std::make_unique<::threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<NodeStateMsg>> msg) {
|
||||
if (!msg->data.self.send_create_request(
|
||||
msg->data.self.serialize_create_request(
|
||||
msg->data.create_view, msg->data.create_consortium)))
|
||||
|
@ -1984,7 +1984,7 @@ namespace ccf
|
|||
create_view,
|
||||
create_consortium);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
threading::get_current_thread_id(), std::move(msg));
|
||||
}
|
||||
|
||||
|
@ -2282,7 +2282,7 @@ namespace ccf
|
|||
{
|
||||
open_user_frontend();
|
||||
|
||||
RINGBUFFER_WRITE_MESSAGE(consensus::ledger_open, to_host);
|
||||
RINGBUFFER_WRITE_MESSAGE(::consensus::ledger_open, to_host);
|
||||
LOG_INFO_FMT("Service open at seqno {}", hook_version);
|
||||
}
|
||||
}));
|
||||
|
@ -2435,7 +2435,7 @@ namespace ccf
|
|||
consensus = std::make_shared<RaftType>(
|
||||
consensus_config,
|
||||
std::make_unique<aft::Adaptor<kv::Store>>(network.tables),
|
||||
std::make_unique<consensus::LedgerEnclave>(writer_factory),
|
||||
std::make_unique<::consensus::LedgerEnclave>(writer_factory),
|
||||
n2n_channels,
|
||||
shared_state,
|
||||
node_client,
|
||||
|
@ -2508,20 +2508,20 @@ namespace ccf
|
|||
writer_factory, network.tables, config.snapshot_tx_interval);
|
||||
}
|
||||
|
||||
void read_ledger_entries(consensus::Index from, consensus::Index to)
|
||||
void read_ledger_entries(::consensus::Index from, ::consensus::Index to)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_get_range,
|
||||
::consensus::ledger_get_range,
|
||||
to_host,
|
||||
from,
|
||||
to,
|
||||
consensus::LedgerRequestPurpose::Recovery);
|
||||
::consensus::LedgerRequestPurpose::Recovery);
|
||||
}
|
||||
|
||||
void ledger_truncate(consensus::Index idx, bool recovery_mode = false)
|
||||
void ledger_truncate(::consensus::Index idx, bool recovery_mode = false)
|
||||
{
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::ledger_truncate, to_host, idx, recovery_mode);
|
||||
::consensus::ledger_truncate, to_host, idx, recovery_mode);
|
||||
}
|
||||
|
||||
void setup_acme_clients()
|
||||
|
@ -2545,8 +2545,8 @@ namespace ccf
|
|||
|
||||
// Start task to periodically check whether any of the certs are
|
||||
// expired.
|
||||
auto msg = std::make_unique<threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<NodeStateMsg>> msg) {
|
||||
auto msg = std::make_unique<::threading::Tmsg<NodeStateMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<NodeStateMsg>> msg) {
|
||||
auto& state = msg->data.self;
|
||||
|
||||
if (state.consensus && state.consensus->can_replicate())
|
||||
|
@ -2571,11 +2571,12 @@ namespace ccf
|
|||
}
|
||||
|
||||
auto delay = std::chrono::minutes(1);
|
||||
ThreadMessaging::instance().add_task_after(std::move(msg), delay);
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), delay);
|
||||
},
|
||||
*this);
|
||||
|
||||
ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), std::chrono::seconds(2));
|
||||
}
|
||||
}
|
||||
|
@ -2628,9 +2629,9 @@ namespace ccf
|
|||
client_cert_key = node_sign_kp->private_key_pem();
|
||||
}
|
||||
|
||||
auto ca = std::make_shared<tls::CA>(ca_certs, true);
|
||||
std::shared_ptr<tls::Cert> ca_cert =
|
||||
std::make_shared<tls::Cert>(ca, client_cert, client_cert_key);
|
||||
auto ca = std::make_shared<::tls::CA>(ca_certs, true);
|
||||
std::shared_ptr<::tls::Cert> ca_cert =
|
||||
std::make_shared<::tls::Cert>(ca, client_cert, client_cert_key);
|
||||
auto client = rpcsessions->create_client(ca_cert, app_protocol);
|
||||
client->connect(
|
||||
url.host,
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace ccf
|
|||
// private data. If the server was malicious and the certificate chain was
|
||||
// bogus, the verification of the endorsement of the quote would fail
|
||||
// anyway.
|
||||
return rpcsessions->create_client(std::make_shared<tls::Cert>(
|
||||
return rpcsessions->create_client(std::make_shared<::tls::Cert>(
|
||||
nullptr, std::nullopt, std::nullopt, std::nullopt, false));
|
||||
}
|
||||
|
||||
|
@ -111,8 +111,8 @@ namespace ccf
|
|||
|
||||
// Start watchdog to send request on new server if it is unresponsive
|
||||
auto msg = std::make_unique<
|
||||
threading::Tmsg<QuoteEndorsementsClientTimeoutMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<QuoteEndorsementsClientTimeoutMsg>>
|
||||
::threading::Tmsg<QuoteEndorsementsClientTimeoutMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<QuoteEndorsementsClientTimeoutMsg>>
|
||||
msg) {
|
||||
if (msg->data.self->has_completed)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ namespace ccf
|
|||
endpoint,
|
||||
last_received_request_id);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg),
|
||||
std::chrono::milliseconds(server_connection_timeout_s * 1000));
|
||||
}
|
||||
|
@ -252,9 +252,10 @@ namespace ccf
|
|||
}
|
||||
|
||||
auto msg =
|
||||
std::make_unique<threading::Tmsg<QuoteEndorsementsClientMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<QuoteEndorsementsClientMsg>>
|
||||
msg) { msg->data.self->fetch(msg->data.server); },
|
||||
std::make_unique<::threading::Tmsg<QuoteEndorsementsClientMsg>>(
|
||||
[](
|
||||
std::unique_ptr<::threading::Tmsg<QuoteEndorsementsClientMsg>>
|
||||
msg) { msg->data.self->fetch(msg->data.server); },
|
||||
shared_from_this(),
|
||||
server);
|
||||
|
||||
|
@ -264,7 +265,7 @@ namespace ccf
|
|||
endpoint,
|
||||
retry_after_s);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
std::move(msg), std::chrono::milliseconds(retry_after_s * 1000));
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{ \
|
||||
out.FIELD = it->get<decltype(TYPE::FIELD)>(); \
|
||||
} \
|
||||
catch (JsonParseError & jpe) \
|
||||
catch (ccf::JsonParseError & jpe) \
|
||||
{ \
|
||||
jpe.pointer_elements.push_back(#FIELD); \
|
||||
throw; \
|
||||
|
@ -19,7 +19,7 @@
|
|||
const auto it = j.find(#FIELD); \
|
||||
if (it == j.end()) \
|
||||
{ \
|
||||
throw JsonParseError(fmt::format( \
|
||||
throw ccf::JsonParseError(fmt::format( \
|
||||
"Missing required field '" #FIELD "' in object:", j.dump())); \
|
||||
} \
|
||||
FROM_JSON_TRY_PARSE(TYPE, FIELD) \
|
||||
|
@ -53,7 +53,7 @@ namespace ccf
|
|||
{
|
||||
if (!j.is_object())
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Cannot parse Receipt LeafComponents: Expected object, got {}",
|
||||
j.dump()));
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace ccf
|
|||
{
|
||||
if (!j.is_object())
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Cannot parse Receipt Step: Expected object, got {}", j.dump()));
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ namespace ccf
|
|||
const auto r_it = j.find("right");
|
||||
if ((l_it == j.end()) == (r_it == j.end()))
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Cannot parse Receipt Step: Expected either 'left' or 'right' field, "
|
||||
"got {}",
|
||||
j.dump()));
|
||||
|
@ -168,7 +168,7 @@ namespace ccf
|
|||
{
|
||||
if (receipt == nullptr)
|
||||
{
|
||||
throw JsonParseError(
|
||||
throw ccf::JsonParseError(
|
||||
fmt::format("Cannot serialise Receipt to JSON: Got nullptr"));
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ namespace ccf
|
|||
{
|
||||
if (!j.is_object())
|
||||
{
|
||||
throw JsonParseError(
|
||||
throw ccf::JsonParseError(
|
||||
fmt::format("Cannot parse Receipt: Expected object, got {}", j.dump()));
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace ccf
|
|||
}
|
||||
else
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Cannot parse Receipt: Expected 'leaf_components' and 'proof'"
|
||||
"fields, got {}",
|
||||
j.dump()));
|
||||
|
@ -248,7 +248,7 @@ namespace ccf
|
|||
sig_receipt->signed_root =
|
||||
leaf_it->get<decltype(SignatureReceipt::signed_root)>();
|
||||
}
|
||||
catch (JsonParseError& jpe)
|
||||
catch (ccf::JsonParseError& jpe)
|
||||
{
|
||||
jpe.pointer_elements.push_back("leaf");
|
||||
throw;
|
||||
|
@ -268,7 +268,7 @@ namespace ccf
|
|||
}
|
||||
else
|
||||
{
|
||||
throw JsonParseError(fmt::format(
|
||||
throw ccf::JsonParseError(fmt::format(
|
||||
"Cannot parse v1 Receipt: Expected either 'leaf' or "
|
||||
"'leaf_components' "
|
||||
"field, got {}",
|
||||
|
|
|
@ -40,14 +40,14 @@ namespace ccf
|
|||
void cleanup()
|
||||
{
|
||||
auto cleanup_msg =
|
||||
std::make_unique<threading::Tmsg<RetiredNodeCleanupMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<RetiredNodeCleanupMsg>> msg) {
|
||||
std::make_unique<::threading::Tmsg<RetiredNodeCleanupMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<RetiredNodeCleanupMsg>> msg) {
|
||||
msg->data.self.send_cleanup_retired_nodes();
|
||||
},
|
||||
*this);
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
threading::get_current_thread_id(), std::move(cleanup_msg));
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
ccf::threading::get_current_thread_id(), std::move(cleanup_msg));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -39,7 +39,7 @@ namespace ccf
|
|||
|
||||
virtual std::shared_ptr<Session> create_session(
|
||||
const std::string& protocol_name,
|
||||
tls::ConnID conn_id,
|
||||
ccf::tls::ConnID conn_id,
|
||||
const std::unique_ptr<tls::Context>&& ctx) override
|
||||
{
|
||||
auto it = session_creation_functions.find(protocol_name);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace ccf
|
|||
|
||||
struct TimeoutTask
|
||||
{
|
||||
threading::TaskQueue::TimerEntry timer_entry;
|
||||
::threading::TaskQueue::TimerEntry timer_entry;
|
||||
uint16_t thread_id;
|
||||
};
|
||||
|
||||
|
@ -66,17 +66,17 @@ namespace ccf
|
|||
|
||||
struct CancelTimerMsg
|
||||
{
|
||||
threading::TaskQueue::TimerEntry timer_entry;
|
||||
::threading::TaskQueue::TimerEntry timer_entry;
|
||||
};
|
||||
|
||||
std::unique_ptr<threading::Tmsg<SendTimeoutErrorMsg>>
|
||||
std::unique_ptr<::threading::Tmsg<SendTimeoutErrorMsg>>
|
||||
create_timeout_error_task(
|
||||
const ccf::NodeId& to,
|
||||
size_t client_session_id,
|
||||
const std::chrono::milliseconds& timeout)
|
||||
{
|
||||
return std::make_unique<threading::Tmsg<SendTimeoutErrorMsg>>(
|
||||
[](std::unique_ptr<threading::Tmsg<SendTimeoutErrorMsg>> msg) {
|
||||
return std::make_unique<::threading::Tmsg<SendTimeoutErrorMsg>>(
|
||||
[](std::unique_ptr<::threading::Tmsg<SendTimeoutErrorMsg>> msg) {
|
||||
msg->data.forwarder->send_timeout_error_response(
|
||||
msg->data.to, msg->data.client_session_id, msg->data.timeout);
|
||||
},
|
||||
|
@ -109,15 +109,15 @@ namespace ccf
|
|||
}
|
||||
|
||||
static void cancel_forwarding_task_cb(
|
||||
std::unique_ptr<threading::Tmsg<CancelTimerMsg>> msg)
|
||||
std::unique_ptr<::threading::Tmsg<CancelTimerMsg>> msg)
|
||||
{
|
||||
cancel_forwarding_task(msg->data.timer_entry);
|
||||
}
|
||||
|
||||
static void cancel_forwarding_task(
|
||||
threading::TaskQueue::TimerEntry timer_entry)
|
||||
::threading::TaskQueue::TimerEntry timer_entry)
|
||||
{
|
||||
threading::ThreadMessaging::instance().cancel_timer_task(timer_entry);
|
||||
::threading::ThreadMessaging::instance().cancel_timer_task(timer_entry);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -172,9 +172,9 @@ namespace ccf
|
|||
std::lock_guard<ccf::pal::Mutex> guard(timeout_tasks_lock);
|
||||
command_id = next_command_id++;
|
||||
timeout_tasks[command_id] = {
|
||||
threading::ThreadMessaging::instance().add_task_after(
|
||||
::threading::ThreadMessaging::instance().add_task_after(
|
||||
create_timeout_error_task(to, client_session_id, timeout), timeout),
|
||||
threading::get_current_thread_id()};
|
||||
ccf::threading::get_current_thread_id()};
|
||||
}
|
||||
|
||||
const auto view_opt = session_ctx->active_view;
|
||||
|
@ -459,13 +459,14 @@ namespace ccf
|
|||
auto it = timeout_tasks.find(cmd_id);
|
||||
if (it != timeout_tasks.end())
|
||||
{
|
||||
if (threading::get_current_thread_id() != it->second.thread_id)
|
||||
if (
|
||||
ccf::threading::get_current_thread_id() != it->second.thread_id)
|
||||
{
|
||||
auto msg = std::make_unique<threading::Tmsg<CancelTimerMsg>>(
|
||||
auto msg = std::make_unique<::threading::Tmsg<CancelTimerMsg>>(
|
||||
&cancel_forwarding_task_cb);
|
||||
msg->data.timer_entry = it->second.timer_entry;
|
||||
|
||||
threading::ThreadMessaging::instance().add_task(
|
||||
::threading::ThreadMessaging::instance().add_task(
|
||||
it->second.thread_id, std::move(msg));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -814,7 +814,7 @@ namespace ccf
|
|||
update_metrics(ctx, endpoint);
|
||||
return;
|
||||
}
|
||||
catch (const JsonParseError& e)
|
||||
catch (const ccf::JsonParseError& e)
|
||||
{
|
||||
ctx->clear_response_headers();
|
||||
ctx->set_error(
|
||||
|
|
|
@ -882,7 +882,7 @@ namespace ccf
|
|||
{
|
||||
status = nlohmann::json(status_str.value()).get<NodeStatus>();
|
||||
}
|
||||
catch (const JsonParseError& e)
|
||||
catch (const ccf::JsonParseError& e)
|
||||
{
|
||||
return ccf::make_error(
|
||||
HTTP_STATUS_BAD_REQUEST,
|
||||
|
@ -1628,7 +1628,7 @@ namespace ccf
|
|||
{
|
||||
parsed = body.get<SetJwtPublicSigningKeys>();
|
||||
}
|
||||
catch (const JsonParseError& e)
|
||||
catch (const ccf::JsonParseError& e)
|
||||
{
|
||||
return make_error(
|
||||
HTTP_STATUS_INTERNAL_SERVER_ERROR,
|
||||
|
|
|
@ -27,8 +27,11 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
std::unique_ptr<threading::ThreadMessaging>
|
||||
threading::ThreadMessaging::singleton = nullptr;
|
||||
namespace threading
|
||||
{
|
||||
std::unique_ptr<::threading::ThreadMessaging> ThreadMessaging::singleton =
|
||||
nullptr;
|
||||
};
|
||||
|
||||
using namespace ccf;
|
||||
using namespace std;
|
||||
|
@ -1730,7 +1733,7 @@ int main(int argc, char** argv)
|
|||
std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch());
|
||||
|
||||
threading::ThreadMessaging::init(1);
|
||||
::threading::ThreadMessaging::init(1);
|
||||
crypto::openssl_sha256_init();
|
||||
doctest::Context context;
|
||||
context.applyCommandLine(argc, argv);
|
||||
|
|
|
@ -31,7 +31,7 @@ using TResponse = http::SimpleResponseProcessor::Response;
|
|||
constexpr size_t certificate_validity_period_days = 365;
|
||||
using namespace std::literals;
|
||||
auto valid_from =
|
||||
ds::to_x509_time_string(std::chrono::system_clock::now() - 24h);
|
||||
::ds::to_x509_time_string(std::chrono::system_clock::now() - 24h);
|
||||
auto valid_to = crypto::compute_cert_valid_to_string(
|
||||
valid_from, certificate_validity_period_days);
|
||||
|
||||
|
@ -121,7 +121,7 @@ std::unique_ptr<ccf::NetworkIdentity> make_test_network_ident()
|
|||
{
|
||||
using namespace std::literals;
|
||||
const auto valid_from =
|
||||
ds::to_x509_time_string(std::chrono::system_clock::now() - 24h);
|
||||
::ds::to_x509_time_string(std::chrono::system_clock::now() - 24h);
|
||||
return std::make_unique<ReplicatedNetworkIdentity>(
|
||||
"CN=CCF test network",
|
||||
crypto::service_identity_curve_choice,
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace ccf
|
|||
// host has not yet allocated memory for the snapshot.
|
||||
bool is_stored = false;
|
||||
|
||||
std::optional<consensus::Index> evidence_idx = std::nullopt;
|
||||
std::optional<::consensus::Index> evidence_idx = std::nullopt;
|
||||
|
||||
std::optional<NodeId> node_id = std::nullopt;
|
||||
std::optional<crypto::Pem> node_cert = std::nullopt;
|
||||
|
@ -65,10 +65,10 @@ namespace ccf
|
|||
std::map<uint32_t, SnapshotInfo> pending_snapshots;
|
||||
|
||||
// Initial snapshot index
|
||||
static constexpr consensus::Index initial_snapshot_idx = 0;
|
||||
static constexpr ::consensus::Index initial_snapshot_idx = 0;
|
||||
|
||||
// Index at which the latest snapshot was generated
|
||||
consensus::Index last_snapshot_idx = 0;
|
||||
::consensus::Index last_snapshot_idx = 0;
|
||||
|
||||
// Used to suspend snapshot generation during public recovery
|
||||
bool snapshot_generation_enabled = true;
|
||||
|
@ -77,21 +77,24 @@ namespace ccf
|
|||
// indicate whether a snapshot was forced at the given index
|
||||
struct SnapshotEntry
|
||||
{
|
||||
consensus::Index idx;
|
||||
::consensus::Index idx;
|
||||
bool forced;
|
||||
bool done;
|
||||
};
|
||||
std::deque<SnapshotEntry> next_snapshot_indices;
|
||||
|
||||
void commit_snapshot(
|
||||
consensus::Index snapshot_idx,
|
||||
::consensus::Index snapshot_idx,
|
||||
const std::vector<uint8_t>& serialised_receipt)
|
||||
{
|
||||
// The snapshot_idx is used to retrieve the correct snapshot file
|
||||
// previously generated.
|
||||
auto to_host = writer_factory.create_writer_to_outside();
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::snapshot_commit, to_host, snapshot_idx, serialised_receipt);
|
||||
::consensus::snapshot_commit,
|
||||
to_host,
|
||||
snapshot_idx,
|
||||
serialised_receipt);
|
||||
}
|
||||
|
||||
struct SnapshotMsg
|
||||
|
@ -101,7 +104,7 @@ namespace ccf
|
|||
uint32_t generation_count;
|
||||
};
|
||||
|
||||
static void snapshot_cb(std::unique_ptr<threading::Tmsg<SnapshotMsg>> msg)
|
||||
static void snapshot_cb(std::unique_ptr<::threading::Tmsg<SnapshotMsg>> msg)
|
||||
{
|
||||
msg->data.self->snapshot_(
|
||||
std::move(msg->data.snapshot), msg->data.generation_count);
|
||||
|
@ -173,7 +176,7 @@ namespace ccf
|
|||
|
||||
auto to_host = writer_factory.create_writer_to_outside();
|
||||
RINGBUFFER_WRITE_MESSAGE(
|
||||
consensus::snapshot_allocate,
|
||||
::consensus::snapshot_allocate,
|
||||
to_host,
|
||||
snapshot_version,
|
||||
evidence_version,
|
||||
|
@ -190,7 +193,7 @@ namespace ccf
|
|||
ws_digest);
|
||||
}
|
||||
|
||||
void update_indices(consensus::Index idx)
|
||||
void update_indices(::consensus::Index idx)
|
||||
{
|
||||
while ((next_snapshot_indices.size() > 1) &&
|
||||
(std::next(next_snapshot_indices.begin())->idx <= idx))
|
||||
|
@ -254,7 +257,7 @@ namespace ccf
|
|||
snapshot_generation_enabled = enabled;
|
||||
}
|
||||
|
||||
void set_last_snapshot_idx(consensus::Index idx)
|
||||
void set_last_snapshot_idx(::consensus::Index idx)
|
||||
{
|
||||
// Should only be called once, after a snapshot has been applied
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
@ -330,7 +333,7 @@ namespace ccf
|
|||
return true;
|
||||
}
|
||||
|
||||
bool record_committable(consensus::Index idx) override
|
||||
bool record_committable(::consensus::Index idx) override
|
||||
{
|
||||
// Returns true if the committable idx will require the generation of a
|
||||
// snapshot, and thus a new ledger chunk
|
||||
|
@ -345,7 +348,7 @@ namespace ccf
|
|||
bool forced = store->flag_enabled_unsafe(
|
||||
kv::AbstractStore::Flag::SNAPSHOT_AT_NEXT_SIGNATURE);
|
||||
|
||||
consensus::Index last_unforced_idx = last_snapshot_idx;
|
||||
::consensus::Index last_unforced_idx = last_snapshot_idx;
|
||||
for (auto it = next_snapshot_indices.rbegin();
|
||||
it != next_snapshot_indices.rend();
|
||||
it++)
|
||||
|
@ -372,7 +375,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
void record_signature(
|
||||
consensus::Index idx,
|
||||
::consensus::Index idx,
|
||||
const std::vector<uint8_t>& sig,
|
||||
const NodeId& node_id,
|
||||
const crypto::Pem& node_cert)
|
||||
|
@ -400,7 +403,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
void record_serialised_tree(
|
||||
consensus::Index idx, const std::vector<uint8_t>& tree)
|
||||
::consensus::Index idx, const std::vector<uint8_t>& tree)
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
||||
|
@ -424,7 +427,7 @@ namespace ccf
|
|||
}
|
||||
|
||||
void record_snapshot_evidence_idx(
|
||||
consensus::Index idx, const SnapshotHash& snapshot)
|
||||
::consensus::Index idx, const SnapshotHash& snapshot)
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
||||
|
@ -442,19 +445,19 @@ namespace ccf
|
|||
}
|
||||
}
|
||||
|
||||
void schedule_snapshot(consensus::Index idx)
|
||||
void schedule_snapshot(::consensus::Index idx)
|
||||
{
|
||||
static uint32_t generation_count = 0;
|
||||
auto msg = std::make_unique<threading::Tmsg<SnapshotMsg>>(&snapshot_cb);
|
||||
auto msg = std::make_unique<::threading::Tmsg<SnapshotMsg>>(&snapshot_cb);
|
||||
msg->data.self = shared_from_this();
|
||||
msg->data.snapshot = store->snapshot_unsafe_maps(idx);
|
||||
msg->data.generation_count = generation_count++;
|
||||
|
||||
auto& tm = threading::ThreadMessaging::instance();
|
||||
auto& tm = ::threading::ThreadMessaging::instance();
|
||||
tm.add_task(tm.get_execution_thread(generation_count), std::move(msg));
|
||||
}
|
||||
|
||||
void commit(consensus::Index idx, bool generate_snapshot) override
|
||||
void commit(::consensus::Index idx, bool generate_snapshot) override
|
||||
{
|
||||
// If generate_snapshot is true, takes a snapshot of the key value store
|
||||
// at the last snapshottable index before idx, and schedule snapshot
|
||||
|
@ -504,7 +507,7 @@ namespace ccf
|
|||
}
|
||||
}
|
||||
|
||||
void rollback(consensus::Index idx) override
|
||||
void rollback(::consensus::Index idx) override
|
||||
{
|
||||
std::lock_guard<ccf::pal::Mutex> guard(lock);
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ static std::pair<std::string, size_t> make_validity_pair(bool expired)
|
|||
if (expired)
|
||||
{
|
||||
return std::make_pair(
|
||||
ds::to_x509_time_string(now - std::chrono::days(2 * validity_days)),
|
||||
::ds::to_x509_time_string(now - std::chrono::days(2 * validity_days)),
|
||||
validity_days);
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_pair(ds::to_x509_time_string(now - 24h), validity_days);
|
||||
return std::make_pair(::ds::to_x509_time_string(now - 24h), validity_days);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,13 +302,13 @@ TEST_CASE("StateCache point queries")
|
|||
{
|
||||
const uint8_t* data = write.contents.data();
|
||||
size_t size = write.contents.size();
|
||||
REQUIRE(write.m == consensus::ledger_get_range);
|
||||
REQUIRE(write.m == ::consensus::ledger_get_range);
|
||||
auto [from_seqno_, to_seqno_, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
auto& from_seqno = from_seqno_;
|
||||
auto& to_seqno = to_seqno_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(from_seqno == to_seqno);
|
||||
// Despite multiple calls for each seqno, the host only sees a single
|
||||
// request for each
|
||||
|
@ -330,13 +330,13 @@ TEST_CASE("StateCache point queries")
|
|||
const auto& write = stub_writer->writes[0];
|
||||
const uint8_t* data = write.contents.data();
|
||||
size_t size = write.contents.size();
|
||||
REQUIRE(write.m == consensus::ledger_get_range);
|
||||
REQUIRE(write.m == ::consensus::ledger_get_range);
|
||||
auto [from_seqno_, to_seqno_, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
auto& from_seqno = from_seqno_;
|
||||
auto& to_seqno = to_seqno_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(from_seqno == to_seqno);
|
||||
REQUIRE(from_seqno == low_seqno);
|
||||
stub_writer->writes.clear();
|
||||
|
@ -891,13 +891,13 @@ TEST_CASE("Incremental progress")
|
|||
const auto& write = stub_writer->writes[0];
|
||||
const uint8_t* data = write.contents.data();
|
||||
size_t size = write.contents.size();
|
||||
REQUIRE(write.m == consensus::ledger_get_range);
|
||||
REQUIRE(write.m == ::consensus::ledger_get_range);
|
||||
auto [from_seqno_, to_seqno_, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
auto& from_seqno = from_seqno_;
|
||||
auto& to_seqno = to_seqno_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(from_seqno == from);
|
||||
REQUIRE(to_seqno == to);
|
||||
|
||||
|
@ -1134,12 +1134,13 @@ TEST_CASE("StateCache concurrent access")
|
|||
{
|
||||
auto data = write.contents.data();
|
||||
auto size = write.contents.size();
|
||||
if (write.m == consensus::ledger_get_range)
|
||||
if (write.m == ::consensus::ledger_get_range)
|
||||
{
|
||||
const auto [from_seqno, to_seqno, purpose_] =
|
||||
ringbuffer::read_message<consensus::ledger_get_range>(data, size);
|
||||
ringbuffer::read_message<::consensus::ledger_get_range>(data, size);
|
||||
auto& purpose = purpose_;
|
||||
REQUIRE(purpose == consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
REQUIRE(
|
||||
purpose == ::consensus::LedgerRequestPurpose::HistoricalQuery);
|
||||
|
||||
std::vector<uint8_t> combined;
|
||||
for (auto seqno = from_seqno; seqno <= to_seqno; ++seqno)
|
||||
|
|
|
@ -162,7 +162,7 @@ PICOBENCH(append_compact<1000>).iterations(sizes).samples(10);
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
logger::config::level() = LoggerLevel::FATAL;
|
||||
threading::ThreadMessaging::init(1);
|
||||
::threading::ThreadMessaging::init(1);
|
||||
crypto::openssl_sha256_init();
|
||||
|
||||
picobench::runner runner;
|
||||
|
|
|
@ -33,10 +33,10 @@ auto read_ringbuffer_out(ringbuffer::Circuit& circuit)
|
|||
-1, [&idx](ringbuffer::Message m, const uint8_t* data, size_t size) {
|
||||
switch (m)
|
||||
{
|
||||
case consensus::snapshot_allocate:
|
||||
case consensus::snapshot_commit:
|
||||
case ::consensus::snapshot_allocate:
|
||||
case ::consensus::snapshot_commit:
|
||||
{
|
||||
auto idx_ = serialized::read<consensus::Index>(data, size);
|
||||
auto idx_ = serialized::read<::consensus::Index>(data, size);
|
||||
idx = {m, idx_};
|
||||
break;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ auto read_ringbuffer_out(ringbuffer::Circuit& circuit)
|
|||
|
||||
auto read_snapshot_allocate_out(ringbuffer::Circuit& circuit)
|
||||
{
|
||||
std::optional<std::tuple<consensus::Index, size_t, uint32_t>>
|
||||
std::optional<std::tuple<::consensus::Index, size_t, uint32_t>>
|
||||
snapshot_allocate_out = std::nullopt;
|
||||
circuit.read_from_inside().read(
|
||||
-1,
|
||||
|
@ -60,17 +60,17 @@ auto read_snapshot_allocate_out(ringbuffer::Circuit& circuit)
|
|||
ringbuffer::Message m, const uint8_t* data, size_t size) {
|
||||
switch (m)
|
||||
{
|
||||
case consensus::snapshot_allocate:
|
||||
case ::consensus::snapshot_allocate:
|
||||
{
|
||||
auto idx = serialized::read<consensus::Index>(data, size);
|
||||
serialized::read<consensus::Index>(data, size);
|
||||
auto idx = serialized::read<::consensus::Index>(data, size);
|
||||
serialized::read<::consensus::Index>(data, size);
|
||||
auto requested_size = serialized::read<size_t>(data, size);
|
||||
auto generation_count = serialized::read<uint32_t>(data, size);
|
||||
|
||||
snapshot_allocate_out = {idx, requested_size, generation_count};
|
||||
break;
|
||||
}
|
||||
case consensus::snapshot_commit:
|
||||
case ::consensus::snapshot_commit:
|
||||
{
|
||||
REQUIRE(false);
|
||||
break;
|
||||
|
@ -252,7 +252,7 @@ TEST_CASE("Regular snapshotting")
|
|||
snapshotter->commit(commit_idx, true);
|
||||
REQUIRE(
|
||||
read_ringbuffer_out(eio) ==
|
||||
rb_msg({consensus::snapshot_commit, snapshot_idx}));
|
||||
rb_msg({::consensus::snapshot_commit, snapshot_idx}));
|
||||
}
|
||||
|
||||
INFO("Subsequent commit before next snapshot idx has no effect");
|
||||
|
@ -295,7 +295,7 @@ TEST_CASE("Regular snapshotting")
|
|||
snapshotter->commit(commit_idx, true);
|
||||
REQUIRE(
|
||||
read_ringbuffer_out(eio) ==
|
||||
rb_msg({consensus::snapshot_commit, snapshot_idx}));
|
||||
rb_msg({::consensus::snapshot_commit, snapshot_idx}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ TEST_CASE("Rollback before snapshot is committed")
|
|||
snapshotter->commit(commit_idx, true);
|
||||
REQUIRE(
|
||||
read_ringbuffer_out(eio) ==
|
||||
rb_msg({consensus::snapshot_commit, snapshot_idx}));
|
||||
rb_msg({::consensus::snapshot_commit, snapshot_idx}));
|
||||
}
|
||||
|
||||
INFO("Force a snapshot");
|
||||
|
@ -420,7 +420,7 @@ TEST_CASE("Rollback before snapshot is committed")
|
|||
snapshotter->commit(commit_idx, true);
|
||||
REQUIRE(
|
||||
read_ringbuffer_out(eio) ==
|
||||
rb_msg({consensus::snapshot_commit, snapshot_idx}));
|
||||
rb_msg({::consensus::snapshot_commit, snapshot_idx}));
|
||||
|
||||
threading::ThreadMessaging::instance().run_one();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace quic
|
|||
{
|
||||
protected:
|
||||
ringbuffer::WriterPtr to_host;
|
||||
tls::ConnID session_id;
|
||||
ccf::tls::ConnID session_id;
|
||||
size_t execution_thread;
|
||||
|
||||
enum Status
|
||||
|
@ -144,7 +144,7 @@ namespace quic
|
|||
|
||||
void recv_buffered(const uint8_t* data, size_t size, sockaddr addr)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called recv_buffered from incorrect thread");
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace quic
|
|||
|
||||
void send_raw_thread(const std::vector<uint8_t>& data, sockaddr addr)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
"Called send_raw_thread from incorrect thread");
|
||||
|
@ -206,7 +206,7 @@ namespace quic
|
|||
|
||||
void send_buffered(const std::vector<uint8_t>& data, sockaddr addr)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called send_buffered from incorrect thread");
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ namespace quic
|
|||
|
||||
void flush()
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called flush from incorrect thread");
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ namespace quic
|
|||
|
||||
void close_thread()
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called close_thread from incorrect thread");
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ namespace quic
|
|||
|
||||
int handle_recv(uint8_t* buf, size_t len, sockaddr addr)
|
||||
{
|
||||
if (threading::get_current_thread_id() != execution_thread)
|
||||
if (ccf::threading::get_current_thread_id() != execution_thread)
|
||||
{
|
||||
throw std::runtime_error("Called handle_recv from incorrect thread");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace tls
|
||||
{
|
||||
class Client : public Context
|
||||
class Client : public ccf::tls::Context
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<Cert> cert;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <openssl/bio.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
namespace tls
|
||||
namespace ccf::tls
|
||||
{
|
||||
class Context
|
||||
{
|
||||
|
|
|
@ -39,13 +39,14 @@ namespace tls
|
|||
};
|
||||
}
|
||||
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(tls::tls_start, tls::ConnID, std::string);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
tls::tls_connect, tls::ConnID, std::string, std::string);
|
||||
::tls::tls_start, ::tls::ConnID, std::string);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
tls::tls_inbound, tls::ConnID, serializer::ByteRange);
|
||||
::tls::tls_connect, ::tls::ConnID, std::string, std::string);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
tls::tls_outbound, tls::ConnID, serializer::ByteRange);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(tls::tls_stop, tls::ConnID, std::string);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(tls::tls_close, tls::ConnID);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(tls::tls_closed, tls::ConnID);
|
||||
::tls::tls_inbound, ::tls::ConnID, serializer::ByteRange);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(
|
||||
::tls::tls_outbound, ::tls::ConnID, serializer::ByteRange);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(::tls::tls_stop, ::tls::ConnID, std::string);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(::tls::tls_close, ::tls::ConnID);
|
||||
DECLARE_RINGBUFFER_MESSAGE_PAYLOAD(::tls::tls_closed, ::tls::ConnID);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace nontls
|
||||
{
|
||||
class PlaintextServer : public tls::Context
|
||||
class PlaintextServer : public ccf::tls::Context
|
||||
{
|
||||
public:
|
||||
PlaintextServer() : Context(false) {}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace tls
|
|||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
|
||||
class Server : public Context
|
||||
class Server : public ccf::tls::Context
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<Cert> cert;
|
||||
|
|
|
@ -164,7 +164,7 @@ long recv(
|
|||
|
||||
/// Performs a TLS handshake, looping until there's nothing more to read/write.
|
||||
/// Returns 0 on success, throws a runtime error with SSL error str on failure.
|
||||
int handshake(Context* ctx, std::atomic<bool>& keep_going)
|
||||
int handshake(ccf::tls::Context* ctx, std::atomic<bool>& keep_going)
|
||||
{
|
||||
while (keep_going)
|
||||
{
|
||||
|
@ -183,26 +183,26 @@ int handshake(Context* ctx, std::atomic<bool>& keep_going)
|
|||
|
||||
case TLS_ERR_NEED_CERT:
|
||||
{
|
||||
LOG_FAIL_FMT("Handshake error: {}", tls::error_string(rc));
|
||||
LOG_FAIL_FMT("Handshake error: {}", ::tls::error_string(rc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
case TLS_ERR_CONN_CLOSE_NOTIFY:
|
||||
{
|
||||
LOG_FAIL_FMT("Handshake error: {}", tls::error_string(rc));
|
||||
LOG_FAIL_FMT("Handshake error: {}", ::tls::error_string(rc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
case TLS_ERR_X509_VERIFY:
|
||||
{
|
||||
auto err = ctx->get_verify_error();
|
||||
LOG_FAIL_FMT("Handshake error: {} [{}]", err, tls::error_string(rc));
|
||||
LOG_FAIL_FMT("Handshake error: {} [{}]", err, ::tls::error_string(rc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
LOG_FAIL_FMT("Handshake error: {}", tls::error_string(rc));
|
||||
LOG_FAIL_FMT("Handshake error: {}", ::tls::error_string(rc));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -261,12 +261,12 @@ NetworkCA get_ca()
|
|||
return {kp, crt};
|
||||
}
|
||||
|
||||
/// Creates a tls::Cert with a new CA using a new self-signed Pem certificate.
|
||||
unique_ptr<tls::Cert> get_dummy_cert(
|
||||
/// Creates a ::tls::Cert with a new CA using a new self-signed Pem certificate.
|
||||
unique_ptr<::tls::Cert> get_dummy_cert(
|
||||
NetworkCA& net_ca, string name, bool auth_required = true)
|
||||
{
|
||||
// Create a CA with a self-signed certificate
|
||||
auto ca = make_unique<tls::CA>(net_ca.cert.str());
|
||||
auto ca = make_unique<::tls::CA>(net_ca.cert.str());
|
||||
|
||||
// Create a signing request and sign with the CA
|
||||
auto kp = crypto::make_key_pair();
|
||||
|
@ -277,13 +277,14 @@ unique_ptr<tls::Cert> get_dummy_cert(
|
|||
auto v = crypto::make_verifier(crt);
|
||||
REQUIRE(v->verify_certificate({&net_ca.cert}));
|
||||
|
||||
// Create a tls::Cert with the CA, the signed certificate and the private key
|
||||
// Create a ::tls::Cert with the CA, the signed certificate and the private
|
||||
// key
|
||||
auto pk = kp->private_key_pem();
|
||||
return make_unique<Cert>(std::move(ca), crt, pk, std::nullopt, auth_required);
|
||||
}
|
||||
|
||||
/// Helper to write past the maximum buffer (16k)
|
||||
int write_helper(Context& handler, const uint8_t* buf, size_t len)
|
||||
int write_helper(ccf::tls::Context& handler, const uint8_t* buf, size_t len)
|
||||
{
|
||||
LOG_DEBUG_FMT("WRITE {} bytes", len);
|
||||
int rc = handler.write(buf, len);
|
||||
|
@ -293,7 +294,7 @@ int write_helper(Context& handler, const uint8_t* buf, size_t len)
|
|||
}
|
||||
|
||||
/// Helper to read past the maximum buffer (16k)
|
||||
int read_helper(Context& handler, uint8_t* buf, size_t len)
|
||||
int read_helper(ccf::tls::Context& handler, uint8_t* buf, size_t len)
|
||||
{
|
||||
LOG_DEBUG_FMT("READ {} bytes", len);
|
||||
int rc = handler.read(buf, len);
|
||||
|
@ -319,8 +320,8 @@ void run_test_case(
|
|||
size_t message_length,
|
||||
const uint8_t* response,
|
||||
size_t response_length,
|
||||
unique_ptr<tls::Cert> server_cert,
|
||||
unique_ptr<tls::Cert> client_cert)
|
||||
unique_ptr<::tls::Cert> server_cert,
|
||||
unique_ptr<::tls::Cert> client_cert)
|
||||
{
|
||||
uint8_t buf[max(message_length, response_length) + 1];
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ using namespace client;
|
|||
|
||||
crypto::Pem key = {};
|
||||
std::string key_id = "Invalid";
|
||||
std::shared_ptr<tls::Cert> tls_cert = nullptr;
|
||||
std::shared_ptr<::tls::Cert> tls_cert = nullptr;
|
||||
|
||||
void read_parquet_file(string generator_filepath, ParquetData& data_handler)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ std::shared_ptr<RpcTlsClient> create_connection(
|
|||
key_id = crypto::Sha256Hash(cert_der).hex_str();
|
||||
|
||||
tls_cert =
|
||||
std::make_shared<tls::Cert>(std::make_shared<tls::CA>(ca), cert_pem, key);
|
||||
std::make_shared<::tls::Cert>(std::make_shared<::tls::CA>(ca), cert_pem, key);
|
||||
}
|
||||
|
||||
const auto [host, port] = ccf::split_net_address(server_address);
|
||||
|
|
Загрузка…
Ссылка в новой задаче