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 ) { log . error ( "Auto-closing channel failed" , e ) ; } } } , new Date ( channel . expiryTimeSeconds ( ) * 1000 + ( System . currentTimeMillis ( ) - Utils . currentTimeMillis ( ) ) ) ) ; } finally { lock . unlock ( ) ; } if ( updateWallet ) updatedChannel ( channel ) ; }
Adds this channel and optionally notifies the wallet of an update to this extension (used during deserialize)