3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 10:45:51 +00:00

Fixed stored channel timers failing

This commit is contained in:
Will Shackleton 2016-02-11 14:47:03 +00:00
parent 09a2ca64d2
commit f1b4db1540
2 changed files with 17 additions and 5 deletions

View File

@ -207,10 +207,16 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
channelTimeoutHandler.schedule(new TimerTask() { channelTimeoutHandler.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup(); try {
removeChannel(channel); TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup();
announcePeerGroup.broadcastTransaction(channel.contract); removeChannel(channel);
announcePeerGroup.broadcastTransaction(channel.refund); 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. // 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()))); }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis())));

View File

@ -190,7 +190,13 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
@Override @Override
public void run() { public void run() {
log.info("Auto-closing channel: {}", channel); log.info("Auto-closing channel: {}", channel);
closeChannel(channel); try {
closeChannel(channel);
} 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);
}
} }
}, autocloseTime); }, autocloseTime);
} finally { } finally {