Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automated node config path args #85

Merged
merged 5 commits into from
Jul 5, 2021
Merged

Conversation

Mirko-von-Leipzig
Copy link
Contributor

The user previously had to specify the location of our generated config file. This change removes this requirement -- since we generate it, we should also pass on the information to the node.

The user previously had to specify the location of our generated config
file. This change removes this requirement -- since we generate it, we
should also pass on the information to the node.
})
};

// insert the config file cmd args
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too happy with the location of this code -- but my brain is too fried to think of a better place.

Happy to get suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably make the change in NodeMetaData::new since that's where it's constructed from the args.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need access to Node::config_filepath() for the actual location of the generated file. We could move that down a layer as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 👍

Copy link
Collaborator

@niklaslong niklaslong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea—left a few suggestions.

})
};

// insert the config file cmd args
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably make the change in NodeMetaData::new since that's where it's constructed from the args.

let start_arg = node
.meta
.start_args
.pop()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably make an insert at i = len - 2 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried that having it twice in a row might be confusing (since its two separate args). But I think yours is still better.

node.meta.start_args.push("--config".into());
node.meta
.start_args
.push(node.config_filepath().into_os_string());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two previous steps could probably be condensed (perhaps with format! and OsString::from)?

Copy link
Contributor Author

@Mirko-von-Leipzig Mirko-von-Leipzig Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason combining the two into one, results in extra quotes around just that pair of args which breaks the command.

So instead of

`arg1 arg2 arg3 arg4 start`

we get

`arg1 arg2 'arg3 arg4' start`

NodeKind::Zebra => {
// Zebra's final arg must be `start`, so we insert the actual args before it.
let n = start_args.len();
assert!(n > 1, "Expected at least one arg for Zebra (`start`)");
Copy link
Collaborator

@niklaslong niklaslong Jul 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might actually want to return a result here instead of panicking for future proofing? (A custom runner would likely need Results to function properly).

@niklaslong niklaslong merged commit c30c8ea into master Jul 5, 2021
@niklaslong niklaslong deleted the feat/improve_config branch July 5, 2021 10:20
zeapoz pushed a commit to zeapoz/zcash that referenced this pull request Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants