iroha icon indicating copy to clipboard operation
iroha copied to clipboard

Replace use of `Duration` for timestamps with an actual timestamp, e.g. `chrono::DateTime`

Open 0x009922 opened this issue 1 year ago • 8 comments

In some places in iroha_data_model, structures use Duration for data which doesn't mean a span of time, but actually means a timestamp. Examples:

  • start: https://github.com/hyperledger/iroha/blob/4362c9427fa8b4090676ac46e8171ef5f1995ff6/data_model/src/events/time.rs#L100-L105
  • since: https://github.com/hyperledger/iroha/blob/4362c9427fa8b4090676ac46e8171ef5f1995ff6/data_model/src/events/time.rs#L126-L131

These fields are timestamps, not time spans.

I propose to use a structure that is designed specifically for timestamps, e.g. chrono::DateTime.

0x009922 avatar Jun 13 '24 23:06 0x009922

Can I work on this issue? I can help around this

hollermay avatar Jun 18 '24 09:06 hollermay

Hi @hollermay, feel free to open a PR.

nxsaken avatar Jun 19 '24 08:06 nxsaken

start should become start_ms and since should become since_ms. However, getters should return something like chrono::DateTime

@hollermay should I assign you?

mversic avatar Jun 19 '24 11:06 mversic

start should become start_ms and since should become since_ms. However, getters should return something like chrono::DateTime

@hollermay should I assign you?

Sure I can give a shot

hollermay avatar Jun 19 '24 11:06 hollermay

also do the same for SignedTransactionV1::creation_time_ms and SignedBlockV1::timestamp_ms

mversic avatar Jun 19 '24 11:06 mversic

@mversic please check the pull request

hollermay avatar Jun 23 '24 18:06 hollermay

u64 is used for timestamps after #4841: https://github.com/hyperledger/iroha/blob/a27bc2eaa7e3cfab6c35cae3b2bcace63a3fee2b/data_model/src/events/time.rs#L100-L105 @mversic should this issue be closed?

dima74 avatar Aug 23 '24 15:08 dima74

No, it's still valid

mversic avatar Aug 23 '24 16:08 mversic

https://github.com/hyperledger-iroha/iroha/pull/5015#issuecomment-3050490455

s8sato avatar Jul 08 '25 22:07 s8sato