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: functions to convert unix epoch to fil epoch #252

Merged
merged 5 commits into from
Nov 24, 2020

Conversation

olizilla
Copy link
Contributor

adds unix_to_height and height_and_unix to translate a unix epoch in seconds to a fil epoch. Makes searching the messages tables more fun.

This is mainnet specific, so this may not be the right approach. I'd need to be able to programmatically set the initial unix epoch time to suport other networks.

License: MIT
Signed-off-by: Oli Evans [email protected]

- adds `unix_to_height` and `height_and_unix` to translate a unix epoch in seconds to a fil epoch

This is mainnet specific, so this may not be the right approach. I'd need to be able to programmatically set the initial unix epoch time to suport other networks

License: MIT
Signed-off-by: Oli Evans <[email protected]>
Copy link
Member

@frrist frrist left a comment

Choose a reason for hiding this comment

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

Good Stuff!

`)

down := batch(`
DROP FUNCTION IF EXISTS public.actor_tips;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be

DROP FUNCTION IF EXISTS public.unix_to_height
DROP FUNCTION IF EXISTS public.height_to_unix

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.

it very very should

- the downs. they were wrong. now they down good.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
License: MIT
Signed-off-by: Oli Evans <[email protected]>
@frrist frrist added the kind/enhancement Improvement to an existing feature label Nov 19, 2020
Copy link
Contributor

@iand iand left a comment

Choose a reason for hiding this comment

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

LGTM but it needs to be changed to migration 20 now

other migrations have landed in the meantime.

License: MIT
Signed-off-by: Oli Evans <[email protected]>
@olizilla
Copy link
Contributor Author

Updated to be migration 21. What's the etiquette round here? This seems innocuous and helpful... I'm ok with them being hardcodded for mainnet only for now. If we made them select the info from a table at runtime, they would be slower, but work for every network... perhaps visor could provide the genesis info to the template at migration time? That sounds more complicated, but seems optimal for perf.

I have no numbers on the perf impact of selecting the genesis info at rumtime, but we want to be able to run this function on every row returned, to convert the height to a time that can be passed to grafana, so I'd assume it'd be worth hardcoding it if we can.

I'm going to deploy the functions manually on the analysis and montoring db today, as they are mainnet specific already, unless anyone objects.

@iand
Copy link
Contributor

iand commented Nov 24, 2020

Happy for you to merge when ready

@olizilla olizilla merged commit 2f13ca1 into master Nov 24, 2020
@olizilla olizilla deleted the olizilla/height-fun branch November 24, 2020 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants