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

Add a toml config parser #23

Closed
ariard opened this issue Jul 7, 2023 · 5 comments
Closed

Add a toml config parser #23

ariard opened this issue Jul 7, 2023 · 5 comments

Comments

@ariard
Copy link
Contributor

ariard commented Jul 7, 2023

civkitd will need a static config file on the host to discover its default settings and learn where is the nostr event database. We have already clap as a dependency so it can be used to build a parser of a TOML config file.

@dapsavoie
Copy link
Contributor

This seems interesting and potentially not too tricky.

I have 2 questions. Firstly, what would an example static config file look like? Secondly, what filepath would it be in? I think I could figure something out here but had these questions first before I draft something.

Thanks

@ariard
Copy link
Contributor Author

ariard commented Jul 14, 2023

Firstly, what would an example static config file look like?

There is an example of bitcoind configuration file available here: https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/bitcoin.conf-annotated.txt

Relevant documentations can be:

Note bitcoin configuration file is not “pure” toml if i’m remembering correctly though approaching the syntax. In my opinion, the main advantage of using TOML over JSON is the ability to add comments (if you have custom settings and wanna remember why years after) and that it’s more straighforward to edit by hand (rather than JSON which is more verbose).

Secondly, what filepath would it be in?

/home/username/.civkitd/civkit.conf if you’re on Linux, I think ? Old school UNIX standard.

If you have more questions, I’m looking forward to answer them, my pleasure.

@dapsavoie
Copy link
Contributor

dapsavoie commented Jul 18, 2023

I would imagine this toml config file would change overtime so the parser script would need to be updated. We could assume a toml like this

[general]
upnp = 1
listen = 1

[performance]
par = 1
dbcache = 1536
blocksonly = 1
maxuploadtarget = 137
mempoolexpiry = 72
maxmempool = 300
maxorphantx = 100

[spam_protection]
limitfreerelay = 10
minrelaytxfee = 0.0001

[connections]
maxconnections = 32

Then I could write a rust script to parse it. Both would need to updated so setting a clear consensus on the pattern for that would be great before writing code. What do you think of using the above as a basis?

@ariard
Copy link
Contributor Author

ariard commented Jul 19, 2023

Yes the example given is a good one and if it can parse something of this complexity for the v0.1 of a toml config parser, I’ll take it.

For the name of the variables, matching civkitd (like testnet=1 or mainnet=1, noise_port, nostr_port, cli_portand max number of subscriptions / relay clients) we can see during the code review.

@ariard
Copy link
Contributor Author

ariard commented Jul 24, 2023

Closed with #29.

@ariard ariard closed this as completed Jul 24, 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

No branches or pull requests

2 participants