-
Notifications
You must be signed in to change notification settings - Fork 166
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
add block id to protocol state #5328
base: master
Are you sure you want to change the base?
Conversation
@@ -698,8 +698,7 @@ func (state *State) Final() protocol.Snapshot { | |||
// - exception for critical unexpected storage errors | |||
func (state *State) AtHeight(height uint64) protocol.Snapshot { | |||
// retrieve the block ID for the finalized height | |||
var blockID flow.Identifier | |||
err := state.db.View(operation.LookupBlockHeight(height, &blockID)) | |||
blockID, err := state.headers.BlockIDByHeight(height) |
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.
Same DB operation, except it reuses the cache from the headers module
@@ -210,7 +210,7 @@ func (e *Engine) BlockProcessable(b *flow.Header, _ *flow.QuorumCertificate) { | |||
return | |||
} | |||
|
|||
blockID := b.ID() | |||
blockID := qc.BlockID |
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.
The caller guarantees the qc is for the block ID, this allows us to save a ID() call
fae702c
to
a45d1a1
Compare
@@ -72,6 +72,10 @@ func (s *Snapshot) Head() (*flow.Header, error) { | |||
return head, err | |||
} | |||
|
|||
func (s *Snapshot) BlockID() (flow.Identifier, error) { |
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.
Some modules already depend on protocol state, however, they still import storage.Headers
, because they need to find blockID by height using the headers.BlockIDByHeight method.
With the BlockID
method added to snapshot along with the changes in the AtHeight method as below, we could use state.AtHeight(height).BlockID()
to replace headers.BlockIDByHeight
, which has been used a lot, and remove the dependency on storage.Headers
.
No description provided.