Skip to content

Conversation

@ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Nov 11, 2025

Why this should be merged

Simplify existing implementation.

How this works

  1. Abstract code to reduce nesting
  2. Restructure Database contents to logically group similar components
  3. Embed blockInfo inside proposal as all fields effectively belong to the proposal anyway

How this was tested

N/A as base branch is still to be tested.

@ARR4N ARR4N requested a review from alarso16 November 11, 2025 14:55
}

type proposals struct {
sync.RWMutex

Choose a reason for hiding this comment

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

Isn't it bad practice to embed this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it's being exposed outside of the package boundary, then there's a risk of misuse leading to deadlock. But as a purely internal struct, what's the value in forcing .lock. or .mu. being added to every call site?

_, ok := p.parent.blockHashes[common.Hash{}]
return ok
})
if !ok { // note negative boolean

Choose a reason for hiding this comment

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

Why add this comment here? I think it might still be unclear what exactly this search is looking for. Maybe we still need a comment describing the hokey "oh it must be the first block after startup" thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why add this comment here?

Because it's the inverse of the one above. Without it, I thought it was too easy to skim and make an incorrect assumption. Similar to this rationale.

I think it might still be unclear what exactly this search is looking for. Maybe we still need a comment describing the hokey "oh it must be the first block after startup" thing

I agree. This refactoring was predominantly about "macro" structure so the larger functions could be broken down into digestable steps before later concentrating on the contents of each one.

@alarso16 alarso16 merged commit a79dd53 into alarso16/firewood-implementation Nov 12, 2025
1 check passed
@alarso16 alarso16 deleted the arr4n/firewood-implementation branch November 12, 2025 19:24
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.

3 participants