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 OpenTimestamps file parser #769

Merged
merged 8 commits into from
Sep 26, 2023
Merged

add OpenTimestamps file parser #769

merged 8 commits into from
Sep 26, 2023

Conversation

fiatjaf
Copy link
Contributor

@fiatjaf fiatjaf commented Sep 26, 2023

https://opentimestamps.org/ (there is no spec or docs about the file format in this website, only libraries).

This is my first time contributing and I don't know if I did this right. I did read the developer guide.

One thing I wanted to know is how to make .ots files be detected automatically. They have this clear extension in their filenames and also an obvious sequence "magic bytes" at their beginning, so it should be pretty easy to detect without having to parse them entirely.

@fiatjaf fiatjaf changed the title opentimestamps: add parser. add OpenTimestamps file parser Sep 26, 2023
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/format.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/ots.go Outdated Show resolved Hide resolved
format/opentimestamps/testdata/hello-world.fqtest Outdated Show resolved Hide resolved
@wader
Copy link
Owner

wader commented Sep 26, 2023

https://opentimestamps.org/ (there is no spec or docs about the file format in this website, only libraries).

Your welcome to add URLs to code etc you used as reference to the top of ots.go or to a ots.md file, also you might want a ots.md file in any case, example file https://github.com/wader/fq/blob/master/format/bson/bson.md and see bson.go about embedding it to have cli help also.

And you can use make doc to regenerate part of the documentation to include your format.

This is my first time contributing and I don't know if I did this right. I did read the developer guide.

🥳 hope it gave some good tips at least

One thing I wanted to know is how to make .ots files be detected automatically. They have this clear extension in their filenames and also an obvious sequence "magic bytes" at their beginning, so it should be pretty easy to detect without having to parse them entirely.

I add a code comment about how automatic detection works. It's is currently solely done on content, maybe in the future a decoder will get access to the filename somehow

BTW the CI error seems to be that a common format test i failing, can updated using WRITE_ACTUAL=1 go test -run TestFormats/all/all.fqtest ./format

@fiatjaf
Copy link
Contributor Author

fiatjaf commented Sep 26, 2023

I think I got it all now.

I don't know what to put on an ots.md file. Where do these CLI docs show up?

I don't have a use case for filtering through these files actually, my initial reason for implementing this was to be able to "see" the entire file in one go, not so much to dig into its sections and so on.

@wader
Copy link
Owner

wader commented Sep 26, 2023

I think I got it all now.

👍

I don't know what to put on an ots.md file. Where do these CLI docs show up?

You can put a author section, links to references, examples and such, but it's optional.

You can show format help with fq -h <format_name> or in the REPL help(<format_name>). It will also be used for doc/formats.md by make doc.

I don't have a use case for filtering through these files actually, my initial reason for implementing this was to be able to "see" the entire file in one go, not so much to dig into its sections and so on.

Ok! but i think it's good to sym map numbers etc to human friendly things, not only for queries but also for when turning it into JSON.

format/opentimestamps/ots.go Outdated Show resolved Hide resolved
@wader
Copy link
Owner

wader commented Sep 26, 2023

Overall it looks good now i think, had just one comment and maybe if you want some documentation. Otherwise i'm ready to merge

@wader
Copy link
Owner

wader commented Sep 26, 2023

Ready to merge?

@fiatjaf
Copy link
Contributor Author

fiatjaf commented Sep 26, 2023

Should be ready now. Added the doc file with some simple examples.

@wader
Copy link
Owner

wader commented Sep 26, 2023

Do one last make doc to add the docs to formats.md

@wader wader merged commit a67427b into wader:master Sep 26, 2023
5 checks passed
@wader
Copy link
Owner

wader commented Sep 26, 2023

Thanks!

@fiatjaf
Copy link
Contributor Author

fiatjaf commented Sep 26, 2023

Thank you very much for merging and for your patience!

@fiatjaf fiatjaf deleted the opentimestamps branch September 26, 2023 19:06
@wader
Copy link
Owner

wader commented Sep 26, 2023

No worries! also reminded me that i should look into minimizing number files needed to change to add a format

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.

None yet

2 participants