private final void removeSelf() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: removeSelf, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canRemoveSelf()) { forceRemoveSelf(); } }
private final synchronized void checkSubItemsOf(Approvable checkingItem) { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { // check referenced items //checkReferencesOf(checkingItem); // check revoking items checkRevokesOf(checkingItem); // check new items checkNewsOf(checkingItem); } } }
public void addWorkCost(QuantiserProcesses process) throws QuantiserException { quantaSum_ += process.getCost(); // System.out.println("Add processing cost for " + process + " (" + process.getCost() + "), now cost is " + quantaSum_ + ", limit is " + quantaLimit_); if (quantaLimit_ >= 0) if (quantaSum_ > quantaLimit_){ // System.out.println("Limit, break "); throw new QuantiserException(); } }
public void obtainNotification(CallbackNotification notification) { node.report(DatagramAdapter.VerboseLevel.DETAILED, "Notify callback ", notification.getId().toBase64String(), " type ", notification.getType().name(), " from node ", notification.getFrom().getName()); if (notification.getType() == CallbackNotification.CallbackNotificationType.COMPLETED) { if (checkCallbackSignature(notification.getSignature())) complete(); } else if (notification.getType() == CallbackNotification.CallbackNotificationType.NOT_RESPONDING) { addNodeToSended(notification.getFrom().getNumber()); checkForComplete(); } }
private final void approveAndCommit() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: approveAndCommit, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) { // todo: fix logic to surely copy approving item dependency. e.g. download original or at least dependencies // first we need to flag our state as approved setState(ItemState.APPROVED); executorService.submit(() -> downloadAndCommit(), Node.this.toString() + toString() + " :: approveAndCommit -> downloadAndCommit"); } }
public final void startResync() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.RESYNCING; resyncingItems.forEach((k, v)-> { resync(k, (re)->onResyncItemFinished(re)); }); } } }
private final void onResyncItemFinished(ResyncingItem ri) { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { resyncingItemsResults.put(ri.hashId, ri.getItemState()); if (resyncingItemsResults.size() >= resyncingItems.size()) { onAllResyncItemsFinished(); } } } }
public void addWorkCostFrom(Quantiser quantiser) throws QuantiserException { quantaSum_ += quantiser.getQuantaSum(); // System.out.println("Add processing cost from " + quantiser.getClass().getSimpleName() + " (" + quantiser.getQuantaSum() + "), now cost is " + quantaSum_ + ", limit is " + quantaLimit_); if (quantaLimit_ >= 0) if (quantaSum_ > quantaLimit_) { // System.out.println("Limit, break "); throw new QuantiserException(); } }
private final void checkSubItems() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { checkSubItemsOf(item); } } }
@Override public String toString() { return "[ParcelNotification from: " + getFrom() + " for parcel: " + parcelId + " and item: " + getItemId() + ", type is: " + type + ", is answer requested: " + answerIsRequested() + "]"; }
@Override public void run() { cleanUp(); } }, 5000, 5000);
/** * Get the cost used for contract processing. * You must first call {@link #check()} method to check contract and calculate cost. * @return cost in quantas */ public int getProcessedCost() { return quantiser.getQuantaSum(); }
@Override public void run() { cleanUp(); } }, 5000, 5000);
public ItemResult getPaymentResult() { if(paymentResult != null) return paymentResult; if(paymentProcessor != null) return paymentProcessor.getResult(); return ItemResult.UNDEFINED; }
public boolean updateConsensusConfig(int nodesCount) { synchronized (this) { if (consensusConfigUpdater != null) { consensusConfigUpdater.updateConsensusConfig(this, nodesCount); return true; } return false; } }
@Override public void run() { cleanUp(); } }, 5000, 5000);
/** * Check if there are deferred follower callback notifications. * * @return true if there are deferred follower callback notifications * */ public boolean hasDeferredNotifications() { return callbackService.hasDeferredNotifications(); } }
public ItemResult getPayloadResult() { if(payloadResult != null) return payloadResult; if(payloadProcessor != null) return payloadProcessor.getResult(); return ItemResult.UNDEFINED; }