mirror of
https://github.com/logos-blockchain/logos-blockchain-module.git
synced 2026-07-14 02:59:52 +00:00
Update with config generation fixes.
This commit is contained in:
parent
2dfe14048d
commit
9681f519f5
@ -82,10 +82,10 @@ namespace {
|
|||||||
uint16_t blend_port_val;
|
uint16_t blend_port_val;
|
||||||
std::string http_addr_data;
|
std::string http_addr_data;
|
||||||
std::string external_address_data;
|
std::string external_address_data;
|
||||||
bool no_public_ip_check_val;
|
|
||||||
std::string custom_deployment_config_path_data;
|
|
||||||
Deployment deployment_val{};
|
|
||||||
std::string state_path_data;
|
std::string state_path_data;
|
||||||
|
bool ibd_val;
|
||||||
|
std::string log_filter_data;
|
||||||
|
std::string kms_file_data;
|
||||||
|
|
||||||
// The FFI struct with pointers into owned data
|
// The FFI struct with pointers into owned data
|
||||||
GenerateConfigArgs ffi_args{};
|
GenerateConfigArgs ffi_args{};
|
||||||
@ -150,39 +150,6 @@ namespace {
|
|||||||
ffi_args.external_address = nullptr;
|
ffi_args.external_address = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no_public_ip_check (bool -> const bool*)
|
|
||||||
if (args.contains("no_public_ip_check") && args["no_public_ip_check"].is_boolean()) {
|
|
||||||
no_public_ip_check_val = args["no_public_ip_check"].get<bool>();
|
|
||||||
ffi_args.no_public_ip_check = &no_public_ip_check_val;
|
|
||||||
} else {
|
|
||||||
ffi_args.no_public_ip_check = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deployment (const struct Deployment*)
|
|
||||||
// Expected format: { "deployment": { "well_known_deployment": "devnet" } }
|
|
||||||
// OR: { "deployment": { "config_path": "/path/to/config" } }
|
|
||||||
if (args.contains("deployment") && args["deployment"].is_object()) {
|
|
||||||
const auto& deployment = args["deployment"];
|
|
||||||
|
|
||||||
if (deployment.contains("well_known_deployment") && deployment["well_known_deployment"].is_string()) {
|
|
||||||
deployment_val.deployment_type = DeploymentType::WellKnown;
|
|
||||||
const std::string wellknown = deployment["well_known_deployment"].get<std::string>();
|
|
||||||
if (wellknown == "devnet") {
|
|
||||||
deployment_val.well_known_deployment = WellKnownDeployment::Devnet;
|
|
||||||
}
|
|
||||||
deployment_val.custom_deployment_config_path = nullptr;
|
|
||||||
} else if (deployment.contains("config_path") && deployment["config_path"].is_string()) {
|
|
||||||
deployment_val.deployment_type = DeploymentType::Custom;
|
|
||||||
deployment_val.well_known_deployment = static_cast<WellKnownDeployment>(0);
|
|
||||||
custom_deployment_config_path_data = deployment["config_path"].get<std::string>();
|
|
||||||
deployment_val.custom_deployment_config_path = custom_deployment_config_path_data.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
ffi_args.deployment = &deployment_val;
|
|
||||||
} else {
|
|
||||||
ffi_args.deployment = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// state_path (string -> const char*)
|
// state_path (string -> const char*)
|
||||||
if (args.contains("state_path") && args["state_path"].is_string()) {
|
if (args.contains("state_path") && args["state_path"].is_string()) {
|
||||||
state_path_data = args["state_path"].get<std::string>();
|
state_path_data = args["state_path"].get<std::string>();
|
||||||
@ -190,6 +157,30 @@ namespace {
|
|||||||
} else {
|
} else {
|
||||||
ffi_args.state_path = nullptr;
|
ffi_args.state_path = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ibd (bool -> const bool*)
|
||||||
|
if (args.contains("ibd") && args["ibd"].is_boolean()) {
|
||||||
|
ibd_val = args["ibd"].get<bool>();
|
||||||
|
ffi_args.ibd = &ibd_val;
|
||||||
|
} else {
|
||||||
|
ffi_args.ibd = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// log_filter (string -> const char*)
|
||||||
|
if (args.contains("log_filter") && args["log_filter"].is_string()) {
|
||||||
|
log_filter_data = args["log_filter"].get<std::string>();
|
||||||
|
ffi_args.log_filter = log_filter_data.c_str();
|
||||||
|
} else {
|
||||||
|
ffi_args.log_filter = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// kms_file (string -> const char*)
|
||||||
|
if (args.contains("kms_file") && args["kms_file"].is_string()) {
|
||||||
|
kms_file_data = args["kms_file"].get<std::string>();
|
||||||
|
ffi_args.kms_file = kms_file_data.c_str();
|
||||||
|
} else {
|
||||||
|
ffi_args.kms_file = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@ -23,23 +23,12 @@ typedef struct LogosBlockchainNode LogosBlockchainNode;
|
|||||||
// Operation status (0 = OK)
|
// Operation status (0 = OK)
|
||||||
typedef int OperationStatus;
|
typedef int OperationStatus;
|
||||||
|
|
||||||
// Deployment enums
|
|
||||||
typedef enum { WellKnown, Custom } DeploymentType;
|
|
||||||
typedef enum { Devnet } WellKnownDeployment;
|
|
||||||
|
|
||||||
// Consensus state enum
|
// Consensus state enum
|
||||||
typedef enum { Bootstrapping, Online } State;
|
typedef enum { Bootstrapping, Online } State;
|
||||||
|
|
||||||
// Key type for generate_key / add_key
|
// Key type for generate_key / add_key
|
||||||
typedef enum { Ed25519, Zk } KeyType;
|
typedef enum { Ed25519, Zk } KeyType;
|
||||||
|
|
||||||
// Deployment configuration
|
|
||||||
typedef struct {
|
|
||||||
DeploymentType deployment_type;
|
|
||||||
WellKnownDeployment well_known_deployment;
|
|
||||||
const char* custom_deployment_config_path;
|
|
||||||
} Deployment;
|
|
||||||
|
|
||||||
// Arguments for generate_user_config
|
// Arguments for generate_user_config
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char** initial_peers;
|
const char** initial_peers;
|
||||||
@ -49,9 +38,10 @@ typedef struct {
|
|||||||
const uint16_t* blend_port;
|
const uint16_t* blend_port;
|
||||||
const char* http_addr;
|
const char* http_addr;
|
||||||
const char* external_address;
|
const char* external_address;
|
||||||
const bool* no_public_ip_check;
|
|
||||||
const Deployment* deployment;
|
|
||||||
const char* state_path;
|
const char* state_path;
|
||||||
|
const bool* ibd;
|
||||||
|
const char* log_filter;
|
||||||
|
const char* kms_file;
|
||||||
} GenerateConfigArgs;
|
} GenerateConfigArgs;
|
||||||
|
|
||||||
// Arguments for transfer_funds
|
// Arguments for transfer_funds
|
||||||
|
|||||||
@ -113,9 +113,10 @@ LOGOS_TEST(generate_user_config_with_all_fields) {
|
|||||||
"blend_port": 9001,
|
"blend_port": 9001,
|
||||||
"http_addr": "0.0.0.0:8080",
|
"http_addr": "0.0.0.0:8080",
|
||||||
"external_address": "1.2.3.4",
|
"external_address": "1.2.3.4",
|
||||||
"no_public_ip_check": true,
|
"state_path": "/tmp/state",
|
||||||
"deployment": { "well_known_deployment": "devnet" },
|
"ibd": true,
|
||||||
"state_path": "/tmp/state"
|
"log_filter": "warn,logos_blockchain=debug",
|
||||||
|
"kms_file": "/tmp/kms.yaml"
|
||||||
})";
|
})";
|
||||||
|
|
||||||
LOGOS_ASSERT_EQ(module.generate_user_config(args), 0);
|
LOGOS_ASSERT_EQ(module.generate_user_config(args), 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user