Skip to content

Use BlockTime rather than Time#416

Merged
quantumagi merged 7 commits intostratisproject:masterfrom
quantumagi:useblocktime
Feb 18, 2021
Merged

Use BlockTime rather than Time#416
quantumagi merged 7 commits intostratisproject:masterfrom
quantumagi:useblocktime

Conversation

@quantumagi
Copy link
Contributor

@quantumagi quantumagi commented Feb 12, 2021

Moving to faster block times may mean that BlockTime could include fractional seconds in the future.

Since using BlockTime versus Time is still logically equivalent we may as well already be using BlockTime instead..

So why this PR? The purpose is to make the future PoA v2 PR smaller by addressing trivial (non-logic-changing) updates separately.

There will be future PRs involving mining timestamp (and the use of BlockTime instead of Time) such as an updated #310.

@quantumagi quantumagi requested a review from fassadlr February 16, 2021 03:44
Copy link
Contributor

@fassadlr fassadlr left a comment

Choose a reason for hiding this comment

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

Looks good, is this backward compatible with the current code? It appears that way... just want you to confirm.


// Look at the last round of blocks to find the previous time that the miner mined.
uint roundTime = this.slotsManager.GetRoundLengthSeconds(federation.Count);
var roundTime = TimeSpan.FromSeconds(this.slotsManager.GetRoundLengthSeconds(federation.Count));
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't GetRoundLengthSeconds already return seconds? Or are you doing TimeSpan cause of the uint return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TimeSpan is more granular than seconds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why dont we then just refactor GetRoundLengthSeconds to return TimeSpan?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@quantumagi
Copy link
Contributor Author

quantumagi commented Feb 17, 2021

Looks good, is this backward compatible with the current code? It appears that way... just want you to confirm.

Yes, that is the intent.

Copy link
Contributor

@fassadlr fassadlr left a comment

Choose a reason for hiding this comment

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

Lets wait for CI 👍

@quantumagi quantumagi merged commit aa4f099 into stratisproject:master Feb 18, 2021
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.

2 participants