public final boolean isPending() { return state.isPending(); }
/** * true if we need to get vote from a node * * @param node we might need vote from * * @return */ private final boolean needsVoteFrom(NodeInfo node) { return record.getState().isPending() && !positiveNodes.contains(node) && !negativeNodes.contains(node); }
/** * Set record to the approved state and saves it. Note that this process does not resolve any dependencies as for * now and does not revoke any records locked for revocation. This could be changed though. */ public void approve() { checkLedgerExists(); // check sanity if (state.isPending()) { setState(ItemState.APPROVED); save(); } else throw new IllegalStateException("attempt to approve record that is not pending: " + state); }
/** * It might happen that the locked record is locked by a zombie or by us which is ok (the latter requires us to reset * lock to us). * * @param lockedRecord * @return true if the lock could be acquired */ private boolean checkLockedRecord(StateRecord lockedRecord) { // It is locked bu us if(lockedRecord.getLockedByRecordId() == recordId ) return true; StateRecord currentOwner = ledger.getLockOwnerOf(lockedRecord); // we can acquire the lock - it is dead if( currentOwner == null ) return true; // valid lock if( currentOwner.state.isPending() ) return false; // This section process data structure errors than can opccur due to unhandled exceptions, data corruption and like // in a safe manner: // The locker is bad? if( currentOwner.state == ItemState.DECLINED || currentOwner.state == ItemState.DISCARDED ) return true; // report inconsistent data. We are not 100% sure this lock could be reacquired, further exploration // needed. As for now, we can't lock it. return false; }
if(binderResult instanceof ItemResult) { ItemResult lastResult = (ItemResult) binderResult; if (millisToWait > 0 && lastResult.state.isPending()) { Instant end = Instant.now().plusMillis(millisToWait); try { Contract c = Contract.fromPackedTransaction(packed); int interval = 1000; while (Instant.now().isBefore(end) && lastResult.state.isPending()) { Thread.currentThread().sleep(interval); if (interval > 300)
while (Instant.now().isBefore(end) && lastResult.state.isPending()) { Thread.currentThread().sleep(interval); interval -= 350;
rr = client.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break;
while(true) { rr = client.getState(contract.getId()); if(!rr.state.isPending()) break;
int attempts = 10; ItemResult itemResult = client.getState(uContract.getId()); while(itemResult.state.isPending() && attempts-- > 0) { itemResult = client.getState(uContract.getId()); Thread.sleep(500);
System.out.println(">> after shutdown state: " + itemResult + " and new " + itemResult2); while (itemResult.state.isPending()) { Thread.currentThread().sleep(500); itemResult = client.getState(parcel.getPayloadContract().getId());
while (itemResult.state.isPending()) { Thread.currentThread().sleep(500); itemResult = client.getState(parcel.getPayloadContract().getId()); System.out.println(">> after restart state: " + itemResult + " and new " + itemResult2); while (itemResult.state.isPending()) { Thread.currentThread().sleep(500); itemResult = client.getState(parcel.getPayloadContract().getId());
System.out.println(ir); Thread.sleep(1000); } while (ir.state.isPending());
System.out.println(rr); Thread.currentThread().sleep(1000); if (!rr.state.isPending()) break; rr = clientKnown.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; rr = client.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; rr = client.getState(contract.getId()); Thread.currentThread().sleep(1000); if (!rr.state.isPending()) break; rr = clientKnown.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break;
private synchronized void waitAndCheckState(Parcel parcel, ItemState waitState) throws Exception { int attemps = 30; ItemResult itemResult; do { itemResult = normalClient.getState(parcel.getPaymentContract().getId()); if(!itemResult.state.isPending()) break; attemps--; if(attemps <= 0) fail("timeout1, parcel " + parcel.getId() + " " + parcel.getPaymentContract().getId() + " " + parcel.getPayloadContract().getId()); Thread.sleep(500); } while(true); assertEquals(ItemState.APPROVED, itemResult.state); attemps = 30; do { itemResult = normalClient.getState(parcel.getPayloadContract().getId()); if(!itemResult.state.isPending()) break; attemps--; if(attemps <= 0) fail("timeout2, parcel " + parcel.getId() + " " + parcel.getPaymentContract().getId() + " " + parcel.getPayloadContract().getId()); Thread.sleep(500); } while(true); assertEquals(waitState, itemResult.state); }
@NonNull ItemResult ir = testSpace.client.register(utnContract.getPackedTransaction()); while(ir.state.isPending()) { Thread.sleep(500); ir = testSpace.client.getState(utnContract.getId()); while(ir.state.isPending()) { Thread.sleep(500); ir = testSpace.client.getState(compound.getId()); while(ir.state.isPending()) { Thread.sleep(500); ir = testSpace.client.getState(batch.getId()); Thread.sleep(500); ir = testSpace.client.getState(sampleContract.getId()); } while (ir.state.isPending()); while(ir.state.isPending()) { Thread.sleep(500); ir = testSpace.client.getState(revocation.getId()); Thread.sleep(500); ir = testSpace.client.getState(sampleContract.getId()); } while (ir.state.isPending());
while (ir.state.isPending()) { ir = testSpace.client.getState(c.getId());
while(true) { rr = absentNodeClient.getState(contract.getId()); if(!rr.state.isPending()) break; Thread.sleep(500);