in accord-core/src/main/java/accord/coordinate/CheckOn.java [176:231]
public Void apply(SafeCommandStore safeStore)
{
switch (sufficientFor.propagate())
{
default: throw new IllegalStateException();
case Accepted:
case AcceptedInvalidate:
// we never "propagate" accepted statuses as these are essentially votes,
// and contribute nothing to our local state machine
throw new IllegalStateException("Invalid states to propagate");
case Invalidated:
Commands.commitInvalidate(safeStore, txnId);
break;
case Applied:
case PreApplied:
if (untilLocalEpoch >= full.executeAt.epoch())
{
confirm(Commands.commit(safeStore, txnId, maxRoute, progressKey, partialTxn, full.executeAt, partialDeps));
confirm(Commands.apply(safeStore, txnId, untilLocalEpoch, maxRoute, full.executeAt, partialDeps, full.writes, full.result));
break;
}
case Committed:
case ReadyToExecute:
confirm(Commands.commit(safeStore, txnId, maxRoute, progressKey, partialTxn, full.executeAt, partialDeps));
break;
case PreCommitted:
Commands.precommit(safeStore, txnId, full.executeAt);
if (!sufficientFor.definition.isKnown())
break;
case PreAccepted:
// only preaccept if we coordinate the transaction
if (untilLocalEpoch <= txnId.epoch() || safeStore.ranges().coordinates(txnId).intersects(maxRoute))
Commands.preaccept(safeStore, txnId, txnId.epoch(), partialTxn, maxRoute, progressKey);
break;
case NotWitnessed:
break;
}
RoutingKey homeKey = merged.homeKey;
if (!merged.durability.isDurable() || homeKey == null)
return null;
if (!safeStore.ranges().coordinates(txnId).contains(homeKey))
return null;
Timestamp executeAt = merged.saveStatus.known.executeAt.hasDecidedExecuteAt() ? merged.executeAt : null;
Commands.setDurability(safeStore, txnId, merged.durability, homeKey, executeAt);
safeStore.progressLog().durable(safeStore.command(txnId).current(), null);
return null;
}