You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that time.Now() returns the same value for every call within a transaction (the block time). But there can be multiple transactions in a block. It would be useful for time.Now() to return different values for each transaction. (For example each call to r/demo/boards to post a message would give a unique message timestamp.) I tried the following goland code which calls time.Now() twice in quick succession:
2024-02-29 14:05:33.265165 +0100 CET m=+0.000095043
2024-02-29 14:05:33.265165 +0100 CET m=+0.000095126
As you can see, even this returns unique values. Go developers may expect this to some extent.
Possible implementation
On a dev call, @moul suggested making each transaction offset the value of time.Now() using the transaction index within the block. For example, timestamp + tx.index * 100us . (The example value of 100us should be configured based on block time and max transactions per block so that a time.Now() value won't overlap with the next block.)
The text was updated successfully, but these errors were encountered:
We won't be handling this feature request before the mainnet launch, primarily due to the bandwidth issues. Will keep open and possibly revisit in the future.
Description
I understand that
time.Now()
returns the same value for every call within a transaction (the block time). But there can be multiple transactions in a block. It would be useful fortime.Now()
to return different values for each transaction. (For example each call to r/demo/boards to post a message would give a unique message timestamp.) I tried the following goland code which callstime.Now()
twice in quick succession:It prints:
As you can see, even this returns unique values. Go developers may expect this to some extent.
Possible implementation
On a dev call, @moul suggested making each transaction offset the value of
time.Now()
using the transaction index within the block. For example, timestamp + tx.index * 100us . (The example value of 100us should be configured based on block time and max transactions per block so that atime.Now()
value won't overlap with the next block.)The text was updated successfully, but these errors were encountered: