Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou committed May 23, 2024
1 parent 0e229a1 commit 325deba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 11 additions & 8 deletions include/ccf/js/modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
#include "ccf/ds/logger.h"
#include "ccf/service/tables/modules.h"
#include "ccf/tx.h"

#include "ccf/version.h"

#include <quickjs/quickjs.h>

namespace ccf::js
{
static inline js::core::JSWrappedValue load_app_module(
JSContext* ctx, const char* module_name, kv::Tx* tx,
JSContext* ctx,
const char* module_name,
kv::Tx* tx,
const std::string& modules_map = ccf::Tables::MODULES,
const std::string& modules_quickjs_bytecode_map = ccf::Tables::MODULES_QUICKJS_BYTECODE,
const std::string& modules_quickjs_version_map = ccf::Tables::MODULES_QUICKJS_VERSION)
const std::string& modules_quickjs_bytecode_map =
ccf::Tables::MODULES_QUICKJS_BYTECODE,
const std::string& modules_quickjs_version_map =
ccf::Tables::MODULES_QUICKJS_VERSION)
{
js::core::Context& jsctx = *(js::core::Context*)JS_GetContextOpaque(ctx);

Expand All @@ -38,13 +41,13 @@ namespace ccf::js
const auto modules = tx->ro<ccf::Modules>(modules_map);

std::optional<std::vector<uint8_t>> bytecode;
const auto modules_quickjs_bytecode = tx->ro<ccf::ModulesQuickJsBytecode>(
modules_quickjs_bytecode_map);
const auto modules_quickjs_bytecode =
tx->ro<ccf::ModulesQuickJsBytecode>(modules_quickjs_bytecode_map);
bytecode = modules_quickjs_bytecode->get(module_name_kv);
if (bytecode)
{
auto modules_quickjs_version = tx->ro<ccf::ModulesQuickJsVersion>(
modules_quickjs_version_map);
auto modules_quickjs_version =
tx->ro<ccf::ModulesQuickJsVersion>(modules_quickjs_version_map);
if (modules_quickjs_version->get() != std::string(ccf::quickjs_version))
bytecode = std::nullopt;
}
Expand Down
7 changes: 4 additions & 3 deletions samples/apps/basic/custom_endpoints/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,12 @@ namespace basicapp
const auto& props = endpoint->properties;
// Needs #6199
auto module_val = ccf::js::load_app_module(
ctx, props.js_module.c_str(), &endpoint_ctx.tx,
ctx,
props.js_module.c_str(),
&endpoint_ctx.tx,
"public:custom_endpoints.modules",
"public:custom_endpoints.modules_quickjs_bytecode",
"public:custom_endpoints.modules_quickjs_version"
);
"public:custom_endpoints.modules_quickjs_version");
export_func = ctx.get_exported_function(
module_val, props.js_function, props.js_module);
}
Expand Down

0 comments on commit 325deba

Please sign in to comment.