private final void onResyncItemFinished(ResyncingItem ri) { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { resyncingItemsResults.put(ri.hashId, ri.getItemState()); if (resyncingItemsResults.size() >= resyncingItems.size()) { onAllResyncItemsFinished(); } } } }
private void pulseDownload() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { if(!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.DOWNLOADING; } synchronized (mutex) { if (item == null && (downloader == null || downloader.isDone())) { downloader = (ScheduledFuture<?>) executorService.submit(() -> download(), Node.this.toString() + toString() + " :: item pulseDownload -> download"); } } } } }
remove.remove(node); if (processingState.isProcessedToConsensus()) { if(processingState.isDone()) { close(); processingState = ItemProcessingState.GOT_CONSENSUS; if (!processingState.isProcessedToConsensus()) return;
if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus() && processingState != ItemProcessingState.POLLING && processingState != ItemProcessingState.CHECKING if(!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.CHECKING;
private final synchronized void checkNewsOf(Approvable checkingItem) { if (!processingState.isProcessedToConsensus()) {
private final synchronized void checkRevokesOf(Approvable checkingItem) { if (!processingState.isProcessedToConsensus()) {
if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { boolean checkPassed = item.getErrors().isEmpty(); if(!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.POLLING;
network.deliver(node, notification); } else { if(processingState.isProcessedToConsensus()) { vote(myInfo, record.getState());
private final void sendStartPollingNotification() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { synchronized (mutex) { if (isPollingExpired()) { // cancel by timeout expired processingState = ItemProcessingState.GOT_CONSENSUS; stopPoller(); stopDownloader(); rollbackChanges(ItemState.UNDEFINED); return; } } // at this point we should requery the nodes that did not yet answered us Notification notification; ParcelNotification.ParcelNotificationType notificationType; if(item.shouldBeU()) { notificationType = ParcelNotification.ParcelNotificationType.PAYMENT; } else { notificationType = ParcelNotification.ParcelNotificationType.PAYLOAD; } notification = new ParcelNotification(myInfo, itemId, parcelId, getResult(), true, notificationType); List<NodeInfo> nodes = network.allNodes(); for(NodeInfo node : nodes) { if (!positiveNodes.contains(node) && !negativeNodes.contains(node)) network.deliver(node, notification); } } } }
private final void itemDownloaded() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: itemDownloaded, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) { synchronized (cache) { cache.put(item, getResult()); } synchronized (mutex) { //save item in disk cache ledger.putItem(record, item, Instant.now().plus(config.getMaxDiskCacheAge())); } if(item instanceof Contract) { if(((Contract)item).isLimitedForTestnet()) { markContractTest((Contract) item); } } if(!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.DOWNLOADED; } if(isCheckingForce) { checkItem(); } downloadedEvent.fire(); } }
private final void pulseStartPolling() { report(getLabel(), () -> concatReportMessage("item processor for item: ", itemId, " from parcel: ", parcelId, " :: pulseStartPolling, state ", processingState, " itemState: ", getState()), DatagramAdapter.VerboseLevel.BASE); if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { // at this point the item is with us, so we can start synchronized (mutex) { if (!processingState.isProcessedToConsensus()) { if (poller == null) { List<Integer> pollTimes = config.getPollTime(); poller = new RunnableWithDynamicPeriod(() -> sendStartPollingNotification(), pollTimes, executorService ); poller.run(); } } } } } }
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 final void startResync() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { processingState = ItemProcessingState.RESYNCING; resyncingItems.forEach((k, v)-> { resync(k, (re)->onResyncItemFinished(re)); }); } } }
private final void checkSubItems() { if(processingState.canContinue()) { if (!processingState.isProcessedToConsensus()) { checkSubItemsOf(item); } } }