/** * Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired * channels found. */ public long getSecondsUntilExpiry(Sha256Hash id) { lock.lock(); try { final Set<StoredClientChannel> setChannels = mapChannels.get(id); final long nowSeconds = Utils.currentTimeSeconds(); int earliestTime = Integer.MAX_VALUE; for (StoredClientChannel channel : setChannels) { synchronized (channel) { if (channel.expiryTimeSeconds() > nowSeconds) earliestTime = Math.min(earliestTime, (int) channel.expiryTimeSeconds()); } } return earliestTime == Integer.MAX_VALUE ? 0 : earliestTime - nowSeconds; } finally { lock.unlock(); } }
/** * Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired * channels found. */ public long getSecondsUntilExpiry(Sha256Hash id) { lock.lock(); try { final Set<StoredClientChannel> setChannels = mapChannels.get(id); final long nowSeconds = Utils.currentTimeSeconds(); int earliestTime = Integer.MAX_VALUE; for (StoredClientChannel channel : setChannels) { synchronized (channel) { if (channel.expiryTimeSeconds() > nowSeconds) earliestTime = Math.min(earliestTime, (int) channel.expiryTimeSeconds()); } } return earliestTime == Integer.MAX_VALUE ? 0 : earliestTime - nowSeconds; } finally { lock.unlock(); } }
/** * Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired * channels found. */ public long getSecondsUntilExpiry(Sha256Hash id) { lock.lock(); try { final Set<StoredClientChannel> setChannels = mapChannels.get(id); final long nowSeconds = Utils.currentTimeSeconds(); int earliestTime = Integer.MAX_VALUE; for (StoredClientChannel channel : setChannels) { synchronized (channel) { if (channel.expiryTimeSeconds() > nowSeconds) earliestTime = Math.min(earliestTime, (int) channel.expiryTimeSeconds()); } } return earliestTime == Integer.MAX_VALUE ? 0 : earliestTime - nowSeconds; } finally { lock.unlock(); } }
/** * Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired * channels found. */ public long getSecondsUntilExpiry(Sha256Hash id) { lock.lock(); try { final Set<StoredClientChannel> setChannels = mapChannels.get(id); final long nowSeconds = Utils.currentTimeSeconds(); int earliestTime = Integer.MAX_VALUE; for (StoredClientChannel channel : setChannels) { synchronized (channel) { if (channel.expiryTimeSeconds() > nowSeconds) earliestTime = Math.min(earliestTime, (int) channel.expiryTimeSeconds()); } } return earliestTime == Integer.MAX_VALUE ? 0 : earliestTime - nowSeconds; } finally { lock.unlock(); } }
private void putChannel(final StoredClientChannel channel, boolean updateWallet) { lock.lock(); try { mapChannels.put(channel.id, channel); channelTimeoutHandler.schedule(new TimerTask() { @Override public void run() { try { TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); removeChannel(channel); announcePeerGroup.broadcastTransaction(channel.contract); announcePeerGroup.broadcastTransaction(channel.refund); } catch (Exception e) { // Something went wrong closing the channel - we catch // here or else we take down the whole Timer. log.error("Auto-closing channel failed", e); } } // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis()))); } finally { lock.unlock(); } if (updateWallet) updatedChannel(channel); }
private void putChannel(final StoredClientChannel channel, boolean updateWallet) { lock.lock(); try { mapChannels.put(channel.id, channel); channelTimeoutHandler.schedule(new TimerTask() { @Override public void run() { try { TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); removeChannel(channel); announcePeerGroup.broadcastTransaction(channel.contract); announcePeerGroup.broadcastTransaction(channel.refund); } catch (Exception e) { // Something went wrong closing the channel - we catch // here or else we take down the whole Timer. log.error("Auto-closing channel failed", e); } } // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis()))); } finally { lock.unlock(); } if (updateWallet) updatedChannel(channel); }
private void putChannel(final StoredClientChannel channel, boolean updateWallet) { lock.lock(); try { mapChannels.put(channel.id, channel); channelTimeoutHandler.schedule(new TimerTask() { @Override public void run() { try { TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); removeChannel(channel); announcePeerGroup.broadcastTransaction(channel.contract); announcePeerGroup.broadcastTransaction(channel.refund); } catch (Exception e) { // Something went wrong closing the channel - we catch // here or else we take down the whole Timer. log.error("Auto-closing channel failed", e); } } // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis()))); } finally { lock.unlock(); } if (updateWallet) updatedChannel(channel); }
private void putChannel(final StoredClientChannel channel, boolean updateWallet) { lock.lock(); try { mapChannels.put(channel.id, channel); channelTimeoutHandler.schedule(new TimerTask() { @Override public void run() { try { TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); removeChannel(channel); announcePeerGroup.broadcastTransaction(channel.contract); announcePeerGroup.broadcastTransaction(channel.refund); } catch (Exception e) { // Something went wrong closing the channel - we catch // here or else we take down the whole Timer. log.error("Auto-closing channel failed", e); } } // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis()))); } finally { lock.unlock(); } if (updateWallet) updatedChannel(channel); }