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() {
@Override
public void run() {
TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup();
removeChannel(channel);
announcePeerGroup.broadcastTransaction(channel.contract);
announcePeerGroup.broadcastTransaction(channel.refund);
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())));

View File

@@ -190,7 +190,13 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
@Override
public void run() {
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);
} finally {