in accord-core/src/main/java/accord/impl/AbstractSafeCommandStore.java [78:141]
public PreLoadContext canExecute(PreLoadContext with)
{
if (with.isEmpty()) return with;
if (with.keys().domain() == Routable.Domain.Range)
return with.isSubsetOf(this.context) ? with : null;
if (!context().keyHistory().satisfiesIfPresent(with.keyHistory()))
return null;
try (Caches caches = tryGetCaches())
{
for (TxnId txnId : with.txnIds())
{
if (null != getInternal(txnId))
continue;
if (caches == null)
return null;
C safeCommand = caches.acquireIfLoaded(txnId);
if (safeCommand == null)
return null;
add(safeCommand, caches);
}
KeyHistory keyHistory = with.keyHistory();
if (keyHistory == KeyHistory.NONE)
return with;
List<RoutingKey> unavailable = null;
Unseekables<?> keys = with.keys();
if (keys.isEmpty())
return with;
for (int i = 0 ; i < keys.size() ; ++i)
{
RoutingKey key = (RoutingKey) keys.get(i);
if (null != getInternal(key))
continue; // already in working set
if (caches != null)
{
CFK safeCfk = caches.acquireIfLoaded(key);
if (safeCfk != null)
{
add(safeCfk, caches);
continue;
}
}
if (unavailable == null)
unavailable = new ArrayList<>();
unavailable.add(key);
}
if (unavailable == null)
return with;
if (unavailable.size() == keys.size())
return null;
return PreLoadContext.contextFor(with.primaryTxnId(), with.additionalTxnId(), keys.without(RoutingKeys.ofSortedUnique(unavailable)), keyHistory);
}
}