mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
DefaultCoinSelector, AllowUnconfirmedCoinSelector: remove singleton pattern
Instantiating these classes is cheap, as they're stateless. And we only do that once per `Wallet` instance.
This commit is contained in:
parent
ac2e244bc8
commit
cd57fea864
2 changed files with 4 additions and 16 deletions
|
@ -23,17 +23,12 @@ import org.bitcoinj.core.Transaction;
|
|||
* confirmed yet. However immature coinbases will not be included (would be a protocol violation).
|
||||
*/
|
||||
public class AllowUnconfirmedCoinSelector extends DefaultCoinSelector {
|
||||
@Override protected boolean shouldSelect(Transaction tx) {
|
||||
@Override
|
||||
protected boolean shouldSelect(Transaction tx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static AllowUnconfirmedCoinSelector instance;
|
||||
|
||||
/** Returns a global static instance of the selector. */
|
||||
public static AllowUnconfirmedCoinSelector get() {
|
||||
// This doesn't have to be thread safe as the object has no state, so discarded duplicates are harmless.
|
||||
if (instance == null)
|
||||
instance = new AllowUnconfirmedCoinSelector();
|
||||
return instance;
|
||||
return new AllowUnconfirmedCoinSelector();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,14 +104,7 @@ public class DefaultCoinSelector implements CoinSelector {
|
|||
(confidence.numBroadcastPeers() > 0 || tx.getParams().network() == BitcoinNetwork.REGTEST);
|
||||
}
|
||||
|
||||
private static DefaultCoinSelector instance;
|
||||
|
||||
/** Returns a global static instance of the selector. */
|
||||
public static DefaultCoinSelector get() {
|
||||
// This doesn't have to be thread safe as the object has no state, so discarded duplicates are
|
||||
// harmless.
|
||||
if (instance == null)
|
||||
instance = new DefaultCoinSelector();
|
||||
return instance;
|
||||
return new DefaultCoinSelector();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue