mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Convert environment config to a key value map (#370)
This commit is contained in:
27
src/conf.cpp
27
src/conf.cpp
@@ -1031,6 +1031,23 @@ namespace conf
|
||||
return -1;
|
||||
}
|
||||
|
||||
contract.bin_path = jdoc["bin_path"].as<std::string>();
|
||||
contract.bin_args = jdoc["bin_args"].as<std::string>();
|
||||
contract.max_input_ledger_offset = jdoc["max_input_ledger_offset"].as<uint16_t>();
|
||||
|
||||
jpath = "contract.environment";
|
||||
for (const auto &obj : jdoc["environment"].object_range())
|
||||
{
|
||||
// Environment variable values should be strings.
|
||||
if (!obj.value().is_string())
|
||||
{
|
||||
std::cerr << jpath << "." << obj.key() << " environment variable should be a string.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
contract.environment.emplace(obj.key(), obj.value().as<std::string>());
|
||||
}
|
||||
|
||||
jpath = "contract.unl";
|
||||
contract.unl.clear();
|
||||
for (auto &nodepk : jdoc["unl"].array_range())
|
||||
@@ -1050,12 +1067,6 @@ namespace conf
|
||||
return -1;
|
||||
}
|
||||
|
||||
contract.bin_path = jdoc["bin_path"].as<std::string>();
|
||||
contract.bin_args = jdoc["bin_args"].as<std::string>();
|
||||
contract.environment = jdoc["environment"].as<std::string>();
|
||||
contract.max_input_ledger_offset = jdoc["max_input_ledger_offset"].as<uint16_t>();
|
||||
|
||||
|
||||
jpath = "contract.consensus";
|
||||
contract.consensus.roundtime = jdoc["consensus"]["roundtime"].as<uint32_t>();
|
||||
if (contract.consensus.roundtime < 1 || contract.consensus.roundtime > MAX_ROUND_TIME)
|
||||
@@ -1109,8 +1120,8 @@ namespace conf
|
||||
|
||||
contract.runtime_env_args.clear();
|
||||
// Populate runtime environment args.
|
||||
if (!contract.environment.empty())
|
||||
util::split_string(contract.runtime_env_args, contract.environment, " ");
|
||||
for (const auto &[key, val] : contract.environment)
|
||||
contract.runtime_env_args.push_back(key + "=" + val);
|
||||
|
||||
contract.runtime_binexec_args.clear();
|
||||
// Populate runtime contract execution args.
|
||||
|
||||
Reference in New Issue
Block a user