Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/pos_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,7 @@ func (bc *Blockchain) processBlockPoS(block *MsgDeSoBlock, currentView uint64, v
return false, false, nil, errors.Wrap(err, "processBlockPoS: Problem applying new tip: ")
}

// 6. Commit grandparent if possible. Only need to do this if we applied a new tip.
if appliedNewTip {
if err = bc.runCommitRuleOnBestChain(verifySignatures); err != nil {
return false, false, nil, errors.Wrap(err,
"processBlockPoS: error running commit rule: ")
}
}

// 7. Notify listeners via the EventManager of which blocks have been removed and added.
// 6. Notify listeners via the EventManager of which blocks have been removed and added.
for ii := len(disconnectedBlockHashes) - 1; ii >= 0; ii-- {
disconnectedBlock := bc.GetBlock(&disconnectedBlockHashes[ii])
if disconnectedBlock == nil {
Expand Down Expand Up @@ -391,6 +383,15 @@ func (bc *Blockchain) processBlockPoS(block *MsgDeSoBlock, currentView uint64, v
}
}

// 7. Commit grandparent if possible. Only need to do this if we applied a new tip.
// MOVED HERE: Commit rule now runs after all error-prone operations complete successfully.
if appliedNewTip {
if err = bc.runCommitRuleOnBestChain(verifySignatures); err != nil {
return false, false, nil, errors.Wrap(err,
"processBlockPoS: error running commit rule: ")
}
}

// Returns whether a new tip was applied, whether the block is an orphan, and any missing blocks, and an error.
return appliedNewTip, false, nil, nil
}
Expand Down