3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

Payment channels: use daemon threads so the VM can exit after the state objects are created.

This commit is contained in:
Mike Hearn 2013-07-13 02:24:19 +02:00
parent 719a786db1
commit 00da963bbb
2 changed files with 14 additions and 18 deletions

View File

@ -16,14 +16,6 @@
package com.google.bitcoin.protocols.channels;
import java.io.*;
import java.math.BigInteger;
import java.util.Date;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.locks.ReentrantLock;
import com.google.bitcoin.core.*;
import com.google.bitcoin.utils.Threading;
import com.google.common.annotations.VisibleForTesting;
@ -31,6 +23,13 @@ import com.google.common.collect.HashMultimap;
import com.google.protobuf.ByteString;
import net.jcip.annotations.GuardedBy;
import java.math.BigInteger;
import java.util.Date;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.locks.ReentrantLock;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@ -42,7 +41,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
static final String EXTENSION_ID = StoredPaymentChannelClientStates.class.getName();
@GuardedBy("lock") @VisibleForTesting final HashMultimap<Sha256Hash, StoredClientChannel> mapChannels = HashMultimap.create();
@VisibleForTesting final Timer channelTimeoutHandler = new Timer();
@VisibleForTesting final Timer channelTimeoutHandler = new Timer(true);
private Wallet containingWallet;
private final TransactionBroadcaster announcePeerGroup;

View File

@ -16,20 +16,17 @@
package com.google.bitcoin.protocols.channels;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import com.google.bitcoin.core.*;
import com.google.bitcoin.utils.Threading;
import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.ByteString;
import net.jcip.annotations.GuardedBy;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import static com.google.common.base.Preconditions.*;
/**
* Keeps track of a set of {@link StoredServerChannel}s and expires them 2 hours before their refund transactions
@ -42,7 +39,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
private final Wallet wallet;
private final TransactionBroadcaster broadcaster;
private final Timer channelTimeoutHandler = new Timer();
private final Timer channelTimeoutHandler = new Timer(true);
private final ReentrantLock lock = Threading.lock("StoredPaymentChannelServerStates");