Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

hdk::now() #2160

Open
ddd-mtl opened this issue Mar 17, 2020 · 4 comments
Open

hdk::now() #2160

ddd-mtl opened this issue Mar 17, 2020 · 4 comments

Comments

@ddd-mtl
Copy link
Contributor

ddd-mtl commented Mar 17, 2020

Hey folks!
I believe it would be quite useful to add a hdk::now() function to the HDK so we can get the current time in the DNA code. We can't use SystemTime in WASM so doing the same kind of wrapper as hdk::sleep() would be enough.
Currently time has to be provided by the UI which is a bit of a useless overhead, and that solution doesn't work for non user-based events like when receiving direct node to node messages.

A quick hack could be to have hdk::sleep() actually return the current time :)

Let me know what you think!

@StaticallyTypedAnxiety
Copy link
Contributor

This is good! I imagine there is going to be some delay between the initial calling of the zome function and the time it gets executed in the wasm, do we care about this?

@ddd-mtl
Copy link
Contributor Author

ddd-mtl commented Mar 28, 2020

I don't if the delay is reasonable. Less than a second lets say.

@StaticallyTypedAnxiety
Copy link
Contributor

This is not hard to implement, I still want to contribute to the project in my spare time so with @zippy 's blessing I could implement this

@Connoropolous
Copy link
Collaborator

Agreed!
There is also the timestamp tacked onto headers, but I've seen code that uses those timestamps and it's really quite tricky and ugly, and doesn't cover all use cases at all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants