private static Validated validate()

in accord-core/src/main/java/accord/local/Commands.java [1367:1422]


    private static Validated validate(@Nullable Ballot ballot, SaveStatus newStatus, Command cur, StoreParticipants participants,
                                      Route<?> addRoute, @Nullable Txn addPartialTxn, @Nullable Deps partialDeps,
                                      @Nullable Commit.Kind commitKind, @Nullable Timestamp executeAt)
    {
        Known haveKnown = cur.known();
        Known expectKnown = newStatus.known;

        Invariants.require(addRoute == participants.route());
        if (expectKnown.has(FullRoute) && !isFullRoute(cur.route()) && !isFullRoute(addRoute))
            return INSUFFICIENT;

        if (expectKnown.definition().isKnown())
        {
            if (cur.txnId().isSystemTxn())
            {
                if (cur.partialTxn() == null && addPartialTxn == null)
                    return INSUFFICIENT;
            }
            else if (haveKnown.definition().isKnown())
            {
                // TODO (desired): avoid converting to participants before subtracting
                Participants<?> extraScope = participants.stillOwns();
                PartialTxn partialTxn = cur.partialTxn();
                if (partialTxn != null)
                    extraScope = extraScope.without(partialTxn.keys().toParticipants());
                if (!containsAll(addPartialTxn, extraScope))
                    return INSUFFICIENT;
            }
            else
            {
                if (!containsAll(addPartialTxn, participants.stillOwns()))
                    return INSUFFICIENT;
            }
        }

        if (!expectKnown.hasAnyDeps())
            return UPDATE_TXN_IGNORE_DEPS;

        if (commitKind == StableMediumPath)
        {
            if (haveKnown.is(DepsProposedFixed) && expectKnown.is(DepsKnown) && ballot != null && ballot.equals(Ballot.ZERO) && participants.stillTouches().equals(cur.participants().touches()))
                return UPDATE_TXN_MERGE_DEPS;
            return INSUFFICIENT;
        }

        if (haveKnown.is(DepsKnown) || (haveKnown.equalDeps(expectKnown) && (ballot == null || ballot.equals(cur.acceptedOrCommitted()))))
            return UPDATE_TXN_KEEP_DEPS;

        if (!containsAll(partialDeps, participants.stillTouches()))
            return INSUFFICIENT;

        if (executeAt != null && expectKnown.is(DepsKnown) && haveKnown.compareTo(DepsFromCoordinator) > 0 && executeAt.equals(cur.txnId()) && !cur.acceptedOrCommitted().equals(Ballot.ZERO))
            return UPDATE_TXN_AND_DEPS_INTERSECT_STABLE;

        return UPDATE_TXN_AND_DEPS;
    }