Skip to content

Commit

Permalink
Merge branch 'master' into json-version
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Jun 19, 2024
2 parents 385bcec + 28b4790 commit 48c854c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions snow/engine/snowman/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,22 +958,15 @@ func (t *Transitive) deliver(
// longer pending
t.removeFromPending(blk)

blkID := blk.ID()
if t.isDecided(blk) || t.Consensus.Processing(blkID) {
// If [blk] is decided, then it shouldn't be added to consensus.
// Similarly, if [blkID] is already in the processing set, it shouldn't
// be added to consensus again.
return t.blocked.Abandon(ctx, blkID)
}

parentID := blk.Parent()
parent, err := t.getBlock(ctx, parentID)
// Because the dependency must have been fulfilled by the time this function
// is called - we don't expect [err] to be non-nil. But it is handled for
// completeness and future proofing.
if err != nil || !(parent.Status() == choices.Accepted || t.Consensus.Processing(parentID)) {
// if the parent isn't processing or the last accepted block, then this
// block is effectively rejected
var (
parentID = blk.Parent()
blkID = blk.ID()
)
if !t.canIssueChildOn(parentID) || t.Consensus.Processing(blkID) {
// If the parent isn't processing or the last accepted block, then this
// block is effectively rejected.
// Additionally, if [blkID] is already in the processing set, it
// shouldn't be added to consensus again.
return t.blocked.Abandon(ctx, blkID)
}

Expand Down Expand Up @@ -1183,6 +1176,13 @@ func (t *Transitive) getProcessingAncestor(ctx context.Context, initialVote ids.
}
}

// canIssueChildOn reports true if it is valid for a child of parentID to be
// verified and added to consensus.
func (t *Transitive) canIssueChildOn(parentID ids.ID) bool {
lastAcceptedID, _ := t.Consensus.LastAccepted()
return parentID == lastAcceptedID || t.Consensus.Processing(parentID)
}

// isDecided reports true if the provided block's status is Accepted, Rejected,
// or if the block's height implies that the block is either Accepted or
// Rejected.
Expand Down

0 comments on commit 48c854c

Please sign in to comment.