Skip to content

Commit 48c854c

Browse files
authored
Merge branch 'master' into json-version
2 parents 385bcec + 28b4790 commit 48c854c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

snow/engine/snowman/transitive.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -958,22 +958,15 @@ func (t *Transitive) deliver(
958958
// longer pending
959959
t.removeFromPending(blk)
960960

961-
blkID := blk.ID()
962-
if t.isDecided(blk) || t.Consensus.Processing(blkID) {
963-
// If [blk] is decided, then it shouldn't be added to consensus.
964-
// Similarly, if [blkID] is already in the processing set, it shouldn't
965-
// be added to consensus again.
966-
return t.blocked.Abandon(ctx, blkID)
967-
}
968-
969-
parentID := blk.Parent()
970-
parent, err := t.getBlock(ctx, parentID)
971-
// Because the dependency must have been fulfilled by the time this function
972-
// is called - we don't expect [err] to be non-nil. But it is handled for
973-
// completeness and future proofing.
974-
if err != nil || !(parent.Status() == choices.Accepted || t.Consensus.Processing(parentID)) {
975-
// if the parent isn't processing or the last accepted block, then this
976-
// block is effectively rejected
961+
var (
962+
parentID = blk.Parent()
963+
blkID = blk.ID()
964+
)
965+
if !t.canIssueChildOn(parentID) || t.Consensus.Processing(blkID) {
966+
// If the parent isn't processing or the last accepted block, then this
967+
// block is effectively rejected.
968+
// Additionally, if [blkID] is already in the processing set, it
969+
// shouldn't be added to consensus again.
977970
return t.blocked.Abandon(ctx, blkID)
978971
}
979972

@@ -1183,6 +1176,13 @@ func (t *Transitive) getProcessingAncestor(ctx context.Context, initialVote ids.
11831176
}
11841177
}
11851178

1179+
// canIssueChildOn reports true if it is valid for a child of parentID to be
1180+
// verified and added to consensus.
1181+
func (t *Transitive) canIssueChildOn(parentID ids.ID) bool {
1182+
lastAcceptedID, _ := t.Consensus.LastAccepted()
1183+
return parentID == lastAcceptedID || t.Consensus.Processing(parentID)
1184+
}
1185+
11861186
// isDecided reports true if the provided block's status is Accepted, Rejected,
11871187
// or if the block's height implies that the block is either Accepted or
11881188
// Rejected.

0 commit comments

Comments
 (0)