Added change roundtime ability for the initiate message (#49)

This commit is contained in:
Chalith Desaman
2021-08-04 09:31:04 +05:30
committed by GitHub
parent f266e8b3fc
commit 7a34defd0e
4 changed files with 12 additions and 2 deletions

View File

@@ -115,6 +115,7 @@ const interatctiveInterface = async () => {
if (modifyContract === 'y' || modifyContract === 'Y') {
unl = await askForInput('Comma seperated UNL <pubkey1>,<pubkey2>,...');
execute = await askForInput('Execute contract? (optional)');
roundtime = await askForInput('Roundtime? (optional)');
log = await askForInput('log <{true|false},max_mbytes_per_file,max_file_count> (optional)');
if (log) {
split = log.split(',');
@@ -129,6 +130,7 @@ const interatctiveInterface = async () => {
}
config.contract = {
execute: execute ? (execute === 'true' ? true : false) : undefined,
roundtime: roundtime ? parseInt(roundtime) : undefined,
log: log ? {
enable: split[0] === 'true' ? true : false,
max_mbytes_per_file: parseInt(split[1]),

View File

@@ -666,6 +666,9 @@ namespace hp
if (config.contract.execute.has_value())
d["contract"]["execute"] = config.contract.execute.value();
if (config.contract.roundtime.has_value())
d["contract"]["roundtime"] = config.contract.roundtime.value();
if (config.contract.log.enable.has_value())
d["contract"]["log"]["enable"] = config.contract.log.enable.value();
@@ -726,7 +729,7 @@ namespace hp
if (config.mesh.msg_forwarding.has_value())
d["mesh"]["msg_forwarding"] = config.mesh.msg_forwarding.value();
if (config.mesh.max_connections.has_value())
d["mesh"]["max_connections"] = config.mesh.max_connections.value();
@@ -741,7 +744,7 @@ namespace hp
if (config.mesh.max_bytes_per_min.has_value())
d["mesh"]["max_bytes_per_min"] = config.mesh.max_bytes_per_min.value();
if (config.mesh.max_bad_msgs_per_min.has_value())
d["mesh"]["max_bad_msgs_per_min"] = config.mesh.max_bad_msgs_per_min.value();

View File

@@ -281,6 +281,9 @@ namespace msg::json
if (contract.contains(msg::FLD_EXECUTE))
msg.config.contract.execute = contract[msg::FLD_EXECUTE].as<bool>();
if (contract.contains(msg::FLD_ROUNDTIME))
msg.config.contract.roundtime = contract[msg::FLD_ROUNDTIME].as<uint32_t>();
if (contract.contains(msg::FLD_LOG))
{
const jsoncons::json &log = contract[msg::FLD_LOG];

View File

@@ -36,6 +36,7 @@ namespace msg
struct contract_config
{
std::optional<uint32_t> roundtime;
std::set<std::string> unl;
std::optional<bool> execute;
c_log_config log;
@@ -139,6 +140,7 @@ namespace msg
constexpr const char *FLD_MESH = "mesh";
constexpr const char *FLD_USER = "user";
constexpr const char *FLD_EXECUTE = "execute";
constexpr const char *FLD_ROUNDTIME = "roundtime";
constexpr const char *FLD_LOG = "log";
constexpr const char *FLD_LOG_LEVEL = "log_level";
constexpr const char *FLD_ENABLE = "enable";