// Adds this channel and optionally notifies the wallet of an update to this extension (used // during deserialize) private void putChannel(final StoredClientChannel channel, boolean updateWallet) { lock.lock(); try { mapChannels.put(channel.id, channel); channelTimeoutHandler.schedule( new TimerTask() { @Override public void run() { TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); removeChannel(channel); announcePeerGroup.broadcastTransaction(channel.contract); announcePeerGroup.broadcastTransaction(channel.refund); } // 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); }
/** This should always be called before attempting to call sendPayment. */ public boolean isExpired() { return paymentDetails.hasExpires() && System.currentTimeMillis() / 1000L > paymentDetails.getExpires(); }