-
Notifications
You must be signed in to change notification settings - Fork 10
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
Previewnet temporary fix for missing timestamps #245
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,6 +613,18 @@ func (b *BlockChainAPI) prepareBlockResponse( | |
Timestamp: hexutil.Uint64(block.Timestamp), | ||
} | ||
|
||
// todo remove after previewnet, temp fix to mock some of the timestamps | ||
if block.Timestamp == 0 { | ||
first := uint64(1715189257) | ||
blockTime := uint64(200) | ||
firstRecordedTimestampBlock := uint64(5493) | ||
|
||
diff := firstRecordedTimestampBlock - block.Height | ||
timestamp := first - blockTime*diff | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be + ? I also think you might multiply it by second. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be - because what I did is checked what is the first timestamp we have indexed, which is: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could have better documented, but this will all go away |
||
|
||
blockResponse.Timestamp = hexutil.Uint64(timestamp) | ||
} | ||
Comment on lines
+616
to
+626
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure the temporary fix is clearly marked and documented. The temporary fix for missing timestamps is clearly marked with a TODO comment. However, it would be beneficial to add more context about why this fix is necessary and any potential impacts. This will help future maintainers understand the reason behind this code and when it can be safely removed. Consider adding a more detailed comment like this: // TODO: Remove after previewnet, temp fix to mock some of the timestamps
// This temporary fix addresses the issue of missing timestamps in previewnet.
// It calculates a mock timestamp based on a predefined starting point and block time.
// This fix should be removed once the underlying issue is resolved. |
||
|
||
transactions, err := b.fetchBlockTransactions(ctx, block) | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just check diff doesn't get negative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did in a local test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add an if statement tho, but then what value to assign :D