Skip to content

Commit

Permalink
Merge branch 'main' into renamespace_http
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Jun 28, 2024
2 parents fea1fa5 + 5bf09ce commit 2eb4b94
Show file tree
Hide file tree
Showing 33 changed files with 136 additions and 130 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: CI

on:
push:
branches:
- main
- gha_ci
pull_request:
workflow_dispatch:

permissions:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `::consensus` is now `ccf::consensus`
- `::tls` is now `ccf::tls`
- `::http` is now `ccf::http`
- `::nonstd` is now `ccf::nonstd`
- `::crypto` is now `ccf::crypto`
- The `programmability` sample app now demonstrates how applications can define their own extensions, creating bindings between C++ and JS state, and allowing JS endpoints to call functions implemented in C++.
- Introduce `DynamicJSEndpointRegistry::record_action_for_audit_v1` and `DynamicJSEndpointRegistry::check_action_not_replayed_v1` to allow an application making use of the programmability feature to easily implement auditability, and protect users allowed to update the application against replay attacks (#6285).
Expand Down
24 changes: 12 additions & 12 deletions include/ccf/ds/json_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ namespace ccf::ds
template <typename T>
inline std::string schema_name()
{
if constexpr (nonstd::is_specialization<T, std::optional>::value)
if constexpr (ccf::nonstd::is_specialization<T, std::optional>::value)
{
return schema_name<typename T::value_type>();
}
else if constexpr (nonstd::is_specialization<T, std::vector>::value)
else if constexpr (ccf::nonstd::is_specialization<T, std::vector>::value)
{
if constexpr (std::is_same<T, std::vector<uint8_t>>::value)
{
Expand All @@ -113,20 +113,20 @@ namespace ccf::ds
return fmt::format("{}_array", schema_name<typename T::value_type>());
}
}
else if constexpr (nonstd::is_specialization<T, std::set>::value)
else if constexpr (ccf::nonstd::is_specialization<T, std::set>::value)
{
return fmt::format("{}_set", schema_name<typename T::value_type>());
}
else if constexpr (
nonstd::is_specialization<T, std::map>::value ||
nonstd::is_specialization<T, std::unordered_map>::value)
ccf::nonstd::is_specialization<T, std::map>::value ||
ccf::nonstd::is_specialization<T, std::unordered_map>::value)
{
return fmt::format(
"{}_to_{}",
schema_name<typename T::key_type>(),
schema_name<typename T::mapped_type>());
}
else if constexpr (nonstd::is_specialization<T, std::pair>::value)
else if constexpr (ccf::nonstd::is_specialization<T, std::pair>::value)
{
return fmt::format(
"{}_and_{}",
Expand Down Expand Up @@ -198,13 +198,13 @@ namespace ccf::ds
template <typename T>
inline void fill_schema(nlohmann::json& schema)
{
if constexpr (nonstd::is_specialization<T, std::optional>::value)
if constexpr (ccf::nonstd::is_specialization<T, std::optional>::value)
{
fill_schema<typename T::value_type>(schema);
}
else if constexpr (
nonstd::is_specialization<T, std::vector>::value ||
nonstd::is_specialization<T, std::set>::value)
ccf::nonstd::is_specialization<T, std::vector>::value ||
ccf::nonstd::is_specialization<T, std::set>::value)
{
if constexpr (std::is_same<T, std::vector<uint8_t>>::value)
{
Expand All @@ -219,8 +219,8 @@ namespace ccf::ds
}
}
else if constexpr (
nonstd::is_specialization<T, std::map>::value ||
nonstd::is_specialization<T, std::unordered_map>::value)
ccf::nonstd::is_specialization<T, std::map>::value ||
ccf::nonstd::is_specialization<T, std::unordered_map>::value)
{
// Nlohmann JSON serialises some maps as objects, if the keys can be
// converted to strings. This should detect those cases. The others are
Expand All @@ -247,7 +247,7 @@ namespace ccf::ds
schema["items"] = items;
}
}
else if constexpr (nonstd::is_specialization<T, std::pair>::value)
else if constexpr (ccf::nonstd::is_specialization<T, std::pair>::value)
{
schema["type"] = "array";
auto items = nlohmann::json::array();
Expand Down
6 changes: 3 additions & 3 deletions include/ccf/ds/nonstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* some are proposed, some are purely custom. They are defined here to avoid
* repetition in other locations.
*/
namespace nonstd
namespace ccf::nonstd
{
/** is_specialization detects type-specialized templates. This does not work
* for value-dependent types (eg - std::array)
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace nonstd
}

/* split_1 wraps split and allows writing things like:
* auto [host, port] = nonstd::split_1("1.2.3.4:8000", ":")
* auto [host, port] = ccf::nonstd::split_1("1.2.3.4:8000", ":")
*/
static inline std::tuple<std::string_view, std::string_view> split_1(
const std::string_view& s, const std::string_view& separator)
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace nonstd

/* rsplit_1 wraps rsplit _and reverses the result order_ and allows writing
* things like:
* auto [host, port] = nonstd::rsplit_1("[1:2:3:4]:8000", ":")
* auto [host, port] = ccf::nonstd::rsplit_1("[1:2:3:4]:8000", ":")
*/
static inline std::tuple<std::string_view, std::string_view> rsplit_1(
const std::string_view& s, const std::string_view& separator)
Expand Down
14 changes: 7 additions & 7 deletions include/ccf/ds/openapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace ccf::ds
{
// HTTP_GET becomes the string "get"
std::string s = llhttp_method_name(verb);
nonstd::to_lower(s);
ccf::nonstd::to_lower(s);
auto& po = access::get_object(path, s);

if (default_responses)
Expand Down Expand Up @@ -275,13 +275,13 @@ namespace ccf::ds
nlohmann::json add_schema_component()
{
nlohmann::json schema;
if constexpr (nonstd::is_specialization<T, std::optional>::value)
if constexpr (ccf::nonstd::is_specialization<T, std::optional>::value)
{
return add_schema_component<typename T::value_type>();
}
else if constexpr (
nonstd::is_specialization<T, std::vector>::value ||
nonstd::is_specialization<T, std::set>::value)
ccf::nonstd::is_specialization<T, std::vector>::value ||
ccf::nonstd::is_specialization<T, std::set>::value)
{
if constexpr (std::is_same<T, std::vector<uint8_t>>::value)
{
Expand All @@ -299,8 +299,8 @@ namespace ccf::ds
document, ccf::ds::json::schema_name<T>(), schema);
}
else if constexpr (
nonstd::is_specialization<T, std::map>::value ||
nonstd::is_specialization<T, std::unordered_map>::value)
ccf::nonstd::is_specialization<T, std::map>::value ||
ccf::nonstd::is_specialization<T, std::unordered_map>::value)
{
if constexpr (nlohmann::detail::
is_compatible_object_type<nlohmann::json, T>::value)
Expand Down Expand Up @@ -330,7 +330,7 @@ namespace ccf::ds
return add_schema_to_components(
document, ccf::ds::json::schema_name<T>(), schema);
}
else if constexpr (nonstd::is_specialization<T, std::pair>::value)
else if constexpr (ccf::nonstd::is_specialization<T, std::pair>::value)
{
schema["type"] = "array";
auto items = nlohmann::json::array();
Expand Down
2 changes: 1 addition & 1 deletion include/ccf/ds/unit_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace ccf::ds
}

auto unit = std::string(unit_begin, input.end());
nonstd::to_lower(unit);
ccf::nonstd::to_lower(unit);
auto value = std::string(input.begin(), unit_begin);

size_t ret = 0;
Expand Down
6 changes: 3 additions & 3 deletions include/ccf/http_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace ccf::http
static ParsedQuery parse_query(const std::string_view& query)
{
ParsedQuery parsed;
const auto params = nonstd::split(query, "&");
const auto params = ccf::nonstd::split(query, "&");
for (const auto& param : params)
{
// NB: This means both `foo=` and `foo` will be accepted and result in a
// `{"foo": ""}` in the map
const auto& [key, value] = nonstd::split_1(param, "=");
const auto& [key, value] = ccf::nonstd::split_1(param, "=");
parsed.emplace(key, value);
}

Expand Down Expand Up @@ -71,7 +71,7 @@ namespace ccf::http
}
else
{
static_assert(nonstd::dependent_false<T>::value, "Unsupported type");
static_assert(ccf::nonstd::dependent_false<T>::value, "Unsupported type");
return false;
}
}
Expand Down
9 changes: 5 additions & 4 deletions include/ccf/kv/serialisers/blit_serialiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace kv::serialisers
{
return SerialisedEntry(t.begin(), t.end());
}
else if constexpr (nonstd::is_std_array<T>::value)
else if constexpr (ccf::nonstd::is_std_array<T>::value)
{
return SerialisedEntry(t.begin(), t.end());
}
Expand All @@ -35,7 +35,7 @@ namespace kv::serialisers
else
{
static_assert(
nonstd::dependent_false<T>::value, "Can't serialise this type");
ccf::nonstd::dependent_false<T>::value, "Can't serialise this type");
}
}

Expand All @@ -45,7 +45,7 @@ namespace kv::serialisers
{
return T(rep.begin(), rep.end());
}
else if constexpr (nonstd::is_std_array<T>::value)
else if constexpr (ccf::nonstd::is_std_array<T>::value)
{
T t;
if (rep.size() != t.size())
Expand Down Expand Up @@ -77,7 +77,8 @@ namespace kv::serialisers
else
{
static_assert(
nonstd::dependent_false<T>::value, "Can't deserialise this type");
ccf::nonstd::dependent_false<T>::value,
"Can't deserialise this type");
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/ccf/rest_verb.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace ccf
inline void to_json(nlohmann::json& j, const RESTVerb& verb)
{
std::string s(verb.c_str());
nonstd::to_lower(s);
ccf::nonstd::to_lower(s);
j = s;
}

Expand All @@ -98,7 +98,7 @@ namespace ccf
}

std::string s = j.get<std::string>();
nonstd::to_upper(s);
ccf::nonstd::to_upper(s);

verb = RESTVerb(s.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion include/ccf/service/node_info_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace ccf
inline static std::pair<std::string, std::string> split_net_address(
const NodeInfoNetwork::NetAddress& addr)
{
auto [host, port] = nonstd::rsplit_1(addr, ":");
auto [host, port] = ccf::nonstd::rsplit_1(addr, ":");
return std::make_pair(std::string(host), std::string(port));
}

Expand Down
2 changes: 1 addition & 1 deletion samples/apps/logging/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ namespace loggingapp
return;
}

const auto terms = nonstd::split(seqnos_s, ",");
const auto terms = ccf::nonstd::split(seqnos_s, ",");
for (const auto& term : terms)
{
size_t val;
Expand Down
4 changes: 2 additions & 2 deletions samples/apps/nobuiltins/nobuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ namespace nobuiltins

auto get_txid = [this](auto& ctx, nlohmann::json&&) {
const auto query_string = ctx.rpc_ctx->get_request_query();
const auto query_params = nonstd::split(query_string, "&");
const auto query_params = ccf::nonstd::split(query_string, "&");
for (const auto& query_param : query_params)
{
const auto& [query_key, query_value] =
nonstd::split_1(query_param, "=");
ccf::nonstd::split_1(query_param, "=");
if (query_key == "seqno")
{
ccf::SeqNo seqno;
Expand Down
6 changes: 3 additions & 3 deletions src/apps/tpcc/app/tpcc_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace tpcc
template <typename T>
constexpr size_t serialised_size()
{
if constexpr (nonstd::is_std_array<T>::value)
if constexpr (ccf::nonstd::is_std_array<T>::value)
{
return std::tuple_size_v<T> * serialised_size<typename T::value_type>();
}
Expand All @@ -40,7 +40,7 @@ namespace tpcc
template <typename T>
void write_value(const T& v, uint8_t*& data, size_t& size)
{
if constexpr (nonstd::is_std_array<T>::value)
if constexpr (ccf::nonstd::is_std_array<T>::value)
{
if constexpr (std::is_integral_v<typename T::value_type>)
{
Expand All @@ -64,7 +64,7 @@ namespace tpcc
template <typename T>
void read_value(T& v, const uint8_t*& data, size_t& size)
{
if constexpr (nonstd::is_std_array<T>::value)
if constexpr (ccf::nonstd::is_std_array<T>::value)
{
if constexpr (std::is_integral_v<typename T::value_type>)
{
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/openssl/key_pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ namespace ccf::crypto
static std::map<std::string, std::string> parse_name(const std::string& name)
{
std::map<std::string, std::string> result;
const auto ns = nonstd::split(name, ",");
const auto ns = ccf::nonstd::split(name, ",");
for (const auto& n : ns)
{
const auto& [key, value] = nonstd::split_1(n, "=");
const auto& [key, value] = ccf::nonstd::split_1(n, "=");
result.emplace(
std::string(key.data(), key.size()),
std::string(value.data(), value.size()));
Expand Down
4 changes: 2 additions & 2 deletions src/ds/ring_buffer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace ringbuffer
return false;

auto next = initial_marker;
nonstd::tuple_for_each(sections, [&](const auto& s) {
ccf::nonstd::tuple_for_each(sections, [&](const auto& s) {
next = write_bytes(next, s->data(), s->size());
});

Expand Down Expand Up @@ -166,7 +166,7 @@ namespace ringbuffer
struct MessageSerializers
{
static_assert(
nonstd::value_dependent_false<ringbuffer::Message, m>::value,
ccf::nonstd::value_dependent_false<ringbuffer::Message, m>::value,
"No payload specialization for this Message");
};

Expand Down
2 changes: 1 addition & 1 deletion src/ds/test/hex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_CASE("Hex string to and from conversion")

std::string uppercase_hex_str("0123456789ABCDEF");
std::string lowercase_hex_str = uppercase_hex_str;
nonstd::to_lower(lowercase_hex_str);
ccf::nonstd::to_lower(lowercase_hex_str);

auto data = ccf::ds::from_hex(uppercase_hex_str);
REQUIRE(data.size() == uppercase_hex_str.size() / 2);
Expand Down
Loading

0 comments on commit 2eb4b94

Please sign in to comment.