public Summary ifRelevant()

in accord-core/src/main/java/accord/local/CommandSummaries.java [185:238]


            public Summary ifRelevant(TxnId txnId, Timestamp executeAt, SaveStatus saveStatus, Participants<?> touches, @Nullable PartialDeps partialDeps)
            {
                SummaryStatus summaryStatus = saveStatus.summary;
                if (summaryStatus == null)
                    return null;

                if (!txnId.is(testKind))
                    return null;

                // start in search key domain, since this is what we consult to decide if can be recovered
                Unseekables<?> intersecting = searchKeysOrRanges.intersecting(touches, Minimal);
                if (intersecting.isEmpty())
                    return null;

                if (redundantBefore != null)
                {
                    // TODO (expected): consider whether this is necessary (and document it).
                    Unseekables<?> newIntersecting = redundantBefore.foldlWithBounds(intersecting, (e, accum, start, end) -> {
                        if (e.gcBefore.compareTo(txnId) <= 0)
                            return accum;
                        return accum.without(Ranges.of(start.rangeFactory().newRange(start, end)));
                    }, intersecting, ignore -> false);

                    if (newIntersecting.isEmpty())
                        return null;

                    intersecting = newIntersecting;
                }

                Invariants.require(partialDeps != null || findAsDep == null || !saveStatus.known.deps().hasProposedOrDecidedDeps());
                IsDep isDep = null;
                if (findAsDep != null)
                {
                    if (partialDeps == null || !isEligibleDep(summaryStatus, findAsDep, txnId, executeAt))
                    {
                        isDep = IsDep.NOT_ELIGIBLE;
                    }
                    else
                    {
                        boolean isCoordDeps = summaryStatus.compareTo(ACCEPTED) < 0;
                        int index = partialDeps.indexOf(findAsDep);
                        // TODO (desired): don't construct participants, pass intersecting as parameter
                        boolean isAnyDep = index >= 0 && partialDeps.isStable(index)
                                              && partialDeps.participants(index).containsAll(intersecting);

                        isDep = isAnyDep ? (isCoordDeps ? IsDep.IS_COORD_DEP     : IsDep.IS_STABLE_DEP)
                                         : (isCoordDeps ? IsDep.IS_NOT_COORD_DEP : IsDep.IS_NOT_STABLE_DEP);
                    }
                }

                // convert to the domain of the command we're loading
                intersecting = touches.intersecting(intersecting, Minimal);
                return new Summary(txnId, executeAt, summaryStatus, intersecting, isDep, findAsDep);
            }