-
Notifications
You must be signed in to change notification settings - Fork 11
consensus/istanbul: add block lock #127
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
Conversation
|
||
// HasBlock implements istanbul.Backend.HashBlock | ||
func (sb *backend) HasBlock(hash common.Hash, number *big.Int) bool { | ||
if h := sb.chain.GetHeaderByHash(hash); h != nil { |
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.
Use GetHeader
and check block nil.
consensus/istanbul/core/core.go
Outdated
// New snapshot for new round | ||
c.current = newRoundState(newView, c.valSet) | ||
// New snapshot for new round. roundChange value implies if locking block is necessary | ||
c.updateRoundState(newView, c.valSet, roundChange) |
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.
We may update round state based on whether it's locked. no need roundChange
if err := c.checkMessage(msgPreprepare, preprepare.View); err != nil { | ||
if err == errOldMessage { | ||
valSet := c.backend.Validators(preprepare.Proposal).Copy() |
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.
Get parent proposal's validator
consensus/istanbul/core/core.go
Outdated
// If it is locked, propose the old proposal | ||
if c.current.IsHashLocked() { | ||
r := &istanbul.Request{ | ||
Proposal: currentProposal, |
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.
Get current proposal from c.current.Prepare.Proposal
consensus/istanbul/core/prepare.go
Outdated
// and we are in earlier state before StatePrepared | ||
if c.current.Prepares.Size() > 2*c.valSet.F() && c.state.Cmp(StatePrepared) < 0 { | ||
if c.current.IsHashLocked() || c.current.Prepares.Size() > 2*c.valSet.F() && c.state.Cmp(StatePrepared) < 0 { |
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.
(c.current.IsHashLocked() || c.current.Prepares.Size() > 2*c.valSet.F()) && c.state.Cmp(StatePrepared) < 0?
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.
LGTM
55d5ba9
to
7daa006
Compare
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.
LGTM
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.
LGTM
…ain backward compatibility (#127)
No description provided.