mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
If possible, use generic type inference for constructing objects.
This commit is contained in:
parent
a06956c6e1
commit
3177bd52a2
@ -42,7 +42,7 @@ public class NativeSecp256k1 {
|
||||
private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
|
||||
private static final Lock r = rwl.readLock();
|
||||
private static final Lock w = rwl.writeLock();
|
||||
private static ThreadLocal<ByteBuffer> nativeECDSABuffer = new ThreadLocal<ByteBuffer>();
|
||||
private static ThreadLocal<ByteBuffer> nativeECDSABuffer = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Verifies the given secp256k1 signature in native code. Calling when enabled == false is undefined (probably
|
||||
|
@ -121,7 +121,7 @@ public abstract class AbstractBlockChain {
|
||||
}
|
||||
// Holds blocks that we have received but can't plug into the chain yet, eg because they were created whilst we
|
||||
// were downloading the block chain.
|
||||
private final LinkedHashMap<Sha256Hash, OrphanBlock> orphanBlocks = new LinkedHashMap<Sha256Hash, OrphanBlock>();
|
||||
private final LinkedHashMap<Sha256Hash, OrphanBlock> orphanBlocks = new LinkedHashMap<>();
|
||||
|
||||
/** False positive estimation uses a double exponential moving average. */
|
||||
public static final double FP_ESTIMATOR_ALPHA = 0.0001;
|
||||
@ -150,9 +150,9 @@ public abstract class AbstractBlockChain {
|
||||
log.info("chain head is at height {}:\n{}", chainHead.getHeight(), chainHead.getHeader());
|
||||
this.params = context.getParams();
|
||||
|
||||
this.newBestBlockListeners = new CopyOnWriteArrayList<ListenerRegistration<NewBestBlockListener>>();
|
||||
this.reorganizeListeners = new CopyOnWriteArrayList<ListenerRegistration<ReorganizeListener>>();
|
||||
this.transactionReceivedListeners = new CopyOnWriteArrayList<ListenerRegistration<TransactionReceivedInBlockListener>>();
|
||||
this.newBestBlockListeners = new CopyOnWriteArrayList<>();
|
||||
this.reorganizeListeners = new CopyOnWriteArrayList<>();
|
||||
this.transactionReceivedListeners = new CopyOnWriteArrayList<>();
|
||||
for (NewBestBlockListener l : wallets) addNewBestBlockListener(Threading.SAME_THREAD, l);
|
||||
for (ReorganizeListener l : wallets) addReorganizeListener(Threading.SAME_THREAD, l);
|
||||
for (TransactionReceivedInBlockListener l : wallets) addTransactionReceivedListener(Threading.SAME_THREAD, l);
|
||||
@ -230,7 +230,7 @@ public abstract class AbstractBlockChain {
|
||||
* Adds a {@link NewBestBlockListener} listener to the chain.
|
||||
*/
|
||||
public final void addNewBestBlockListener(Executor executor, NewBestBlockListener listener) {
|
||||
newBestBlockListeners.add(new ListenerRegistration<NewBestBlockListener>(listener, executor));
|
||||
newBestBlockListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,7 +244,7 @@ public abstract class AbstractBlockChain {
|
||||
* Adds a generic {@link ReorganizeListener} listener to the chain.
|
||||
*/
|
||||
public final void addReorganizeListener(Executor executor, ReorganizeListener listener) {
|
||||
reorganizeListeners.add(new ListenerRegistration<ReorganizeListener>(listener, executor));
|
||||
reorganizeListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +258,7 @@ public abstract class AbstractBlockChain {
|
||||
* Adds a generic {@link TransactionReceivedInBlockListener} listener to the chain.
|
||||
*/
|
||||
public final void addTransactionReceivedListener(Executor executor, TransactionReceivedInBlockListener listener) {
|
||||
transactionReceivedListeners.add(new ListenerRegistration<TransactionReceivedInBlockListener>(listener, executor));
|
||||
transactionReceivedListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -506,7 +506,7 @@ public abstract class AbstractBlockChain {
|
||||
public Set<Sha256Hash> drainOrphanBlocks() {
|
||||
lock.lock();
|
||||
try {
|
||||
Set<Sha256Hash> hashes = new HashSet<Sha256Hash>(orphanBlocks.keySet());
|
||||
Set<Sha256Hash> hashes = new HashSet<>(orphanBlocks.keySet());
|
||||
orphanBlocks.clear();
|
||||
return hashes;
|
||||
} finally {
|
||||
@ -818,7 +818,7 @@ public abstract class AbstractBlockChain {
|
||||
*/
|
||||
private static LinkedList<StoredBlock> getPartialChain(StoredBlock higher, StoredBlock lower, BlockStore store) throws BlockStoreException {
|
||||
checkArgument(higher.getHeight() > lower.getHeight(), "higher and lower are reversed");
|
||||
LinkedList<StoredBlock> results = new LinkedList<StoredBlock>();
|
||||
LinkedList<StoredBlock> results = new LinkedList<>();
|
||||
StoredBlock cursor = higher;
|
||||
while (true) {
|
||||
results.add(cursor);
|
||||
|
@ -76,7 +76,7 @@ public class AddressMessage extends Message {
|
||||
// Guard against ultra large messages that will crash us.
|
||||
if (numAddresses > MAX_ADDRESSES)
|
||||
throw new ProtocolException("Address message too large.");
|
||||
addresses = new ArrayList<PeerAddress>((int) numAddresses);
|
||||
addresses = new ArrayList<>((int) numAddresses);
|
||||
for (int i = 0; i < numAddresses; i++) {
|
||||
PeerAddress addr = new PeerAddress(params, payload, cursor, protocolVersion, this, serializer);
|
||||
addresses.add(addr);
|
||||
|
@ -87,7 +87,7 @@ public class AlertMessage extends Message {
|
||||
}
|
||||
// Using a hashset here is very inefficient given that this will normally be only one item. But Java doesn't
|
||||
// make it easy to do better. What we really want is just an array-backed set.
|
||||
Set<Long> cancelSet = new HashSet<Long>((int) cancelSetSize);
|
||||
Set<Long> cancelSet = new HashSet<>((int) cancelSetSize);
|
||||
for (long i = 0; i < cancelSetSize; i++) {
|
||||
cancelSet.add(readUint32());
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class AlertMessage extends Message {
|
||||
if (subverSetSize < 0 || subverSetSize > MAX_SET_SIZE) {
|
||||
throw new ProtocolException("Bad subver set size: " + subverSetSize);
|
||||
}
|
||||
Set<String> matchingSubVers = new HashSet<String>((int) subverSetSize);
|
||||
Set<String> matchingSubVers = new HashSet<>((int) subverSetSize);
|
||||
for (long i = 0; i < subverSetSize; i++) {
|
||||
matchingSubVers.add(readStr());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class BitcoinSerializer extends MessageSerializer {
|
||||
private final NetworkParameters params;
|
||||
private final boolean parseRetain;
|
||||
|
||||
private static final Map<Class<? extends Message>, String> names = new HashMap<Class<? extends Message>, String>();
|
||||
private static final Map<Class<? extends Message>, String> names = new HashMap<>();
|
||||
|
||||
static {
|
||||
names.put(VersionMessage.class, "version");
|
||||
|
@ -201,7 +201,7 @@ public class Block extends Message {
|
||||
this.time = time;
|
||||
this.difficultyTarget = difficultyTarget;
|
||||
this.nonce = nonce;
|
||||
this.transactions = new LinkedList<Transaction>();
|
||||
this.transactions = new LinkedList<>();
|
||||
this.transactions.addAll(transactions);
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ public class Block extends Message {
|
||||
|
||||
int numTransactions = (int) readVarInt();
|
||||
optimalEncodingMessageSize += VarInt.sizeOf(numTransactions);
|
||||
transactions = new ArrayList<Transaction>(numTransactions);
|
||||
transactions = new ArrayList<>(numTransactions);
|
||||
for (int i = 0; i < numTransactions; i++) {
|
||||
Transaction tx = new Transaction(params, payload, cursor, this, serializer, UNKNOWN_LENGTH);
|
||||
// Label the transaction as coming from the P2P network, so code that cares where we first saw it knows.
|
||||
@ -619,7 +619,7 @@ public class Block extends Message {
|
||||
// 2 3 4 4
|
||||
// / \ / \ / \
|
||||
// t1 t2 t3 t4 t5 t5
|
||||
ArrayList<byte[]> tree = new ArrayList<byte[]>();
|
||||
ArrayList<byte[]> tree = new ArrayList<>();
|
||||
// Start by adding all the hashes of the transactions as leaves of the tree.
|
||||
for (Transaction t : transactions) {
|
||||
tree.add(t.getHash().getBytes());
|
||||
@ -760,7 +760,7 @@ public class Block extends Message {
|
||||
void addTransaction(Transaction t, boolean runSanityChecks) {
|
||||
unCacheTransactions();
|
||||
if (transactions == null) {
|
||||
transactions = new ArrayList<Transaction>();
|
||||
transactions = new ArrayList<>();
|
||||
}
|
||||
t.setParent(this);
|
||||
if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
|
||||
@ -867,7 +867,7 @@ public class Block extends Message {
|
||||
@VisibleForTesting
|
||||
void addCoinbaseTransaction(byte[] pubKeyTo, Coin value, final int height) {
|
||||
unCacheTransactions();
|
||||
transactions = new ArrayList<Transaction>();
|
||||
transactions = new ArrayList<>();
|
||||
Transaction coinbase = new Transaction(params);
|
||||
final ScriptBuilder inputBuilder = new ScriptBuilder();
|
||||
|
||||
|
@ -301,7 +301,7 @@ public class BloomFilter extends Message {
|
||||
*/
|
||||
public synchronized FilteredBlock applyAndUpdate(Block block) {
|
||||
List<Transaction> txns = block.getTransactions();
|
||||
List<Sha256Hash> txHashes = new ArrayList<Sha256Hash>(txns.size());
|
||||
List<Sha256Hash> txHashes = new ArrayList<>(txns.size());
|
||||
List<Transaction> matched = Lists.newArrayList();
|
||||
byte[] bits = new byte[(int) Math.ceil(txns.size() / 8.0)];
|
||||
for (int i = 0; i < txns.size(); i++) {
|
||||
|
@ -76,7 +76,7 @@ public class CheckpointManager {
|
||||
private static final int MAX_SIGNATURES = 256;
|
||||
|
||||
// Map of block header time to data.
|
||||
protected final TreeMap<Long, StoredBlock> checkpoints = new TreeMap<Long, StoredBlock>();
|
||||
protected final TreeMap<Long, StoredBlock> checkpoints = new TreeMap<>();
|
||||
|
||||
protected final NetworkParameters params;
|
||||
protected final Sha256Hash dataHash;
|
||||
|
@ -89,7 +89,7 @@ public class Context {
|
||||
|
||||
private static volatile Context lastConstructed;
|
||||
private static boolean isStrictMode;
|
||||
private static final ThreadLocal<Context> slot = new ThreadLocal<Context>();
|
||||
private static final ThreadLocal<Context> slot = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Returns the current context that is associated with the <b>calling thread</b>. BitcoinJ is an API that has thread
|
||||
|
@ -36,7 +36,7 @@ public class FilteredBlock extends Message {
|
||||
|
||||
// A set of transactions whose hashes are a subset of getTransactionHashes()
|
||||
// These were relayed as a part of the filteredblock getdata, ie likely weren't previously received as loose transactions
|
||||
private Map<Sha256Hash, Transaction> associatedTransactions = new HashMap<Sha256Hash, Transaction>();
|
||||
private Map<Sha256Hash, Transaction> associatedTransactions = new HashMap<>();
|
||||
|
||||
public FilteredBlock(NetworkParameters params, byte[] payloadBytes) throws ProtocolException {
|
||||
super(params, payloadBytes, 0);
|
||||
@ -76,7 +76,7 @@ public class FilteredBlock extends Message {
|
||||
public List<Sha256Hash> getTransactionHashes() throws VerificationException {
|
||||
if (cachedTransactionHashes != null)
|
||||
return Collections.unmodifiableList(cachedTransactionHashes);
|
||||
List<Sha256Hash> hashesMatched = new LinkedList<Sha256Hash>();
|
||||
List<Sha256Hash> hashesMatched = new LinkedList<>();
|
||||
if (header.getMerkleRoot().equals(merkleTree.getTxnHashAndMerkleRoot(hashesMatched))) {
|
||||
cachedTransactionHashes = hashesMatched;
|
||||
return Collections.unmodifiableList(cachedTransactionHashes);
|
||||
|
@ -217,14 +217,14 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
|
||||
blockStore.beginDatabaseBatchWrite();
|
||||
|
||||
LinkedList<UTXO> txOutsSpent = new LinkedList<UTXO>();
|
||||
LinkedList<UTXO> txOutsCreated = new LinkedList<UTXO>();
|
||||
LinkedList<UTXO> txOutsSpent = new LinkedList<>();
|
||||
LinkedList<UTXO> txOutsCreated = new LinkedList<>();
|
||||
long sigOps = 0;
|
||||
|
||||
if (scriptVerificationExecutor.isShutdown())
|
||||
scriptVerificationExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
|
||||
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<Future<VerificationException>>(block.transactions.size());
|
||||
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<>(block.transactions.size());
|
||||
try {
|
||||
if (!params.isCheckpoint(height)) {
|
||||
// BIP30 violator blocks are ones that contain a duplicated transaction. They are all in the
|
||||
@ -247,7 +247,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
boolean isCoinBase = tx.isCoinBase();
|
||||
Coin valueIn = Coin.ZERO;
|
||||
Coin valueOut = Coin.ZERO;
|
||||
final List<Script> prevOutScripts = new LinkedList<Script>();
|
||||
final List<Script> prevOutScripts = new LinkedList<>();
|
||||
final Set<VerifyFlag> verifyFlags = params.getTransactionVerificationFlags(block, tx, getVersionTally(), height);
|
||||
if (!isCoinBase) {
|
||||
// For each input of the transaction remove the corresponding output from the set of unspent
|
||||
@ -308,7 +308,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
|
||||
if (!isCoinBase && runScripts) {
|
||||
// Because correctlySpends modifies transactions, this must come after we are done with tx
|
||||
FutureTask<VerificationException> future = new FutureTask<VerificationException>(new Verifier(tx, prevOutScripts, verifyFlags));
|
||||
FutureTask<VerificationException> future = new FutureTask<>(new Verifier(tx, prevOutScripts, verifyFlags));
|
||||
scriptVerificationExecutor.execute(future);
|
||||
listScriptVerificationResults.add(future);
|
||||
}
|
||||
@ -361,8 +361,8 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
try {
|
||||
List<Transaction> transactions = block.getTransactions();
|
||||
if (transactions != null) {
|
||||
LinkedList<UTXO> txOutsSpent = new LinkedList<UTXO>();
|
||||
LinkedList<UTXO> txOutsCreated = new LinkedList<UTXO>();
|
||||
LinkedList<UTXO> txOutsSpent = new LinkedList<>();
|
||||
LinkedList<UTXO> txOutsCreated = new LinkedList<>();
|
||||
long sigOps = 0;
|
||||
|
||||
if (!params.isCheckpoint(newBlock.getHeight())) {
|
||||
@ -377,14 +377,14 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
|
||||
if (scriptVerificationExecutor.isShutdown())
|
||||
scriptVerificationExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<Future<VerificationException>>(transactions.size());
|
||||
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<>(transactions.size());
|
||||
for (final Transaction tx : transactions) {
|
||||
final Set<VerifyFlag> verifyFlags =
|
||||
params.getTransactionVerificationFlags(newBlock.getHeader(), tx, getVersionTally(), Integer.SIZE);
|
||||
boolean isCoinBase = tx.isCoinBase();
|
||||
Coin valueIn = Coin.ZERO;
|
||||
Coin valueOut = Coin.ZERO;
|
||||
final List<Script> prevOutScripts = new LinkedList<Script>();
|
||||
final List<Script> prevOutScripts = new LinkedList<>();
|
||||
|
||||
if (!isCoinBase) {
|
||||
for (int index = 0; index < tx.getInputs().size(); index++) {
|
||||
@ -439,7 +439,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
|
||||
if (!isCoinBase) {
|
||||
// Because correctlySpends modifies transactions, this must come after we are done with tx
|
||||
FutureTask<VerificationException> future = new FutureTask<VerificationException>(new Verifier(tx, prevOutScripts, verifyFlags));
|
||||
FutureTask<VerificationException> future = new FutureTask<>(new Verifier(tx, prevOutScripts, verifyFlags));
|
||||
scriptVerificationExecutor.execute(future);
|
||||
listScriptVerificationResults.add(future);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class GetBlocksMessage extends Message {
|
||||
if (startCount > 500)
|
||||
throw new ProtocolException("Number of locators cannot be > 500, received: " + startCount);
|
||||
length = cursor - offset + ((startCount + 1) * 32);
|
||||
locator = new ArrayList<Sha256Hash>(startCount);
|
||||
locator = new ArrayList<>(startCount);
|
||||
for (int i = 0; i < startCount; i++) {
|
||||
locator.add(readHash());
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class HeadersMessage extends Message {
|
||||
throw new ProtocolException("Too many headers: got " + numHeaders + " which is larger than " +
|
||||
MAX_HEADERS);
|
||||
|
||||
blockHeaders = new ArrayList<Block>();
|
||||
blockHeaders = new ArrayList<>();
|
||||
final BitcoinSerializer serializer = this.params.getSerializer(true);
|
||||
|
||||
for (int i = 0; i < numHeaders; ++i) {
|
||||
|
@ -47,7 +47,7 @@ public abstract class ListMessage extends Message {
|
||||
|
||||
public ListMessage(NetworkParameters params) {
|
||||
super(params);
|
||||
items = new ArrayList<InventoryItem>();
|
||||
items = new ArrayList<>();
|
||||
length = 1; //length of 0 varint;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public abstract class ListMessage extends Message {
|
||||
length = (int) (cursor - offset + (arrayLen * InventoryItem.MESSAGE_LENGTH));
|
||||
|
||||
// An inv is vector<CInv> where CInv is int+hash. The int is either 1 or 2 for tx or block.
|
||||
items = new ArrayList<InventoryItem>((int) arrayLen);
|
||||
items = new ArrayList<>((int) arrayLen);
|
||||
for (int i = 0; i < arrayLen; i++) {
|
||||
if (cursor + InventoryItem.MESSAGE_LENGTH > payload.length) {
|
||||
throw new ProtocolException("Ran off the end of the INV");
|
||||
|
@ -104,7 +104,7 @@ public abstract class NetworkParameters {
|
||||
protected String[] dnsSeeds;
|
||||
protected int[] addrSeeds;
|
||||
protected HttpDiscovery.Details[] httpSeeds = {};
|
||||
protected Map<Integer, Sha256Hash> checkpoints = new HashMap<Integer, Sha256Hash>();
|
||||
protected Map<Integer, Sha256Hash> checkpoints = new HashMap<>();
|
||||
protected transient MessageSerializer defaultSerializer = null;
|
||||
|
||||
protected NetworkParameters() {
|
||||
|
@ -38,6 +38,6 @@ public class NotFoundMessage extends InventoryMessage {
|
||||
|
||||
public NotFoundMessage(NetworkParameters params, List<InventoryItem> items) {
|
||||
super(params);
|
||||
this.items = new ArrayList<InventoryItem>(items);
|
||||
this.items = new ArrayList<>(items);
|
||||
}
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public class PartialMerkleTree extends Message {
|
||||
int height = 0;
|
||||
while (getTreeWidth(allLeafHashes.size(), height) > 1)
|
||||
height++;
|
||||
List<Boolean> bitList = new ArrayList<Boolean>();
|
||||
List<Sha256Hash> hashes = new ArrayList<Sha256Hash>();
|
||||
List<Boolean> bitList = new ArrayList<>();
|
||||
List<Sha256Hash> hashes = new ArrayList<>();
|
||||
traverseAndBuild(height, 0, allLeafHashes, includeBits, bitList, hashes);
|
||||
byte[] bits = new byte[(int)Math.ceil(bitList.size() / 8.0)];
|
||||
for (int i = 0; i < bitList.size(); i++)
|
||||
@ -116,7 +116,7 @@ public class PartialMerkleTree extends Message {
|
||||
transactionCount = (int)readUint32();
|
||||
|
||||
int nHashes = (int) readVarInt();
|
||||
hashes = new ArrayList<Sha256Hash>(nHashes);
|
||||
hashes = new ArrayList<>(nHashes);
|
||||
for (int i = 0; i < nHashes; i++)
|
||||
hashes.add(readHash());
|
||||
|
||||
|
@ -65,19 +65,19 @@ public class Peer extends PeerSocketHandler {
|
||||
private final Context context;
|
||||
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<BlocksDownloadedEventListener>> blocksDownloadedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<BlocksDownloadedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<ChainDownloadStartedEventListener>> chainDownloadStartedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<ChainDownloadStartedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<PeerConnectedEventListener>> connectedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PeerConnectedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<PeerDisconnectedEventListener>> disconnectedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PeerDisconnectedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<GetDataEventListener>> getDataEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<GetDataEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<PreMessageReceivedEventListener>> preMessageReceivedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PreMessageReceivedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<OnTransactionBroadcastListener>> onTransactionEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<OnTransactionBroadcastListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
// Whether to try and download blocks and transactions from this peer. Set to false by PeerGroup if not the
|
||||
// primary peer. This is to avoid redundant work and concurrency problems with downloading the same chain
|
||||
// in parallel.
|
||||
@ -123,14 +123,14 @@ public class Peer extends PeerSocketHandler {
|
||||
//
|
||||
// It is important to avoid a nasty edge case where we can end up with parallel chain downloads proceeding
|
||||
// simultaneously if we were to receive a newly solved block whilst parts of the chain are streaming to us.
|
||||
private final HashSet<Sha256Hash> pendingBlockDownloads = new HashSet<Sha256Hash>();
|
||||
private final HashSet<Sha256Hash> pendingBlockDownloads = new HashSet<>();
|
||||
// Keep references to TransactionConfidence objects for transactions that were announced by a remote peer, but
|
||||
// which we haven't downloaded yet. These objects are de-duplicated by the TxConfidenceTable class.
|
||||
// Once the tx is downloaded (by some peer), the Transaction object that is created will have a reference to
|
||||
// the confidence object held inside it, and it's then up to the event listeners that receive the Transaction
|
||||
// to keep it pinned to the root set if they care about this data.
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private final HashSet<TransactionConfidence> pendingTxDownloads = new HashSet<TransactionConfidence>();
|
||||
private final HashSet<TransactionConfidence> pendingTxDownloads = new HashSet<>();
|
||||
// The lowest version number we're willing to accept. Lower than this will result in an immediate disconnect.
|
||||
private volatile int vMinProtocolVersion;
|
||||
// When an API user explicitly requests a block or transaction from a peer, the InventoryItem is put here
|
||||
@ -230,12 +230,12 @@ public class Peer extends PeerSocketHandler {
|
||||
this.vDownloadTxDependencyDepth = chain != null ? downloadTxDependencyDepth : 0;
|
||||
this.blockChain = chain; // Allowed to be null.
|
||||
this.vDownloadData = chain != null;
|
||||
this.getDataFutures = new CopyOnWriteArrayList<GetDataRequest>();
|
||||
this.getAddrFutures = new LinkedList<SettableFuture<AddressMessage>>();
|
||||
this.getDataFutures = new CopyOnWriteArrayList<>();
|
||||
this.getAddrFutures = new LinkedList<>();
|
||||
this.fastCatchupTimeSecs = params.getGenesisBlock().getTimeSeconds();
|
||||
this.pendingPings = new CopyOnWriteArrayList<PendingPing>();
|
||||
this.pendingPings = new CopyOnWriteArrayList<>();
|
||||
this.vMinProtocolVersion = params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.PONG);
|
||||
this.wallets = new CopyOnWriteArrayList<Wallet>();
|
||||
this.wallets = new CopyOnWriteArrayList<>();
|
||||
this.context = Context.get();
|
||||
|
||||
this.versionHandshakeFuture.addListener(new Runnable() {
|
||||
@ -348,7 +348,7 @@ public class Peer extends PeerSocketHandler {
|
||||
|
||||
/** Registers a listener that is called when messages are received. */
|
||||
public void addGetDataEventListener(Executor executor, GetDataEventListener listener) {
|
||||
getDataEventListeners.add(new ListenerRegistration<GetDataEventListener>(listener, executor));
|
||||
getDataEventListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/** Registers a listener that is called when a transaction is broadcast across the network */
|
||||
@ -358,7 +358,7 @@ public class Peer extends PeerSocketHandler {
|
||||
|
||||
/** Registers a listener that is called when a transaction is broadcast across the network */
|
||||
public void addOnTransactionBroadcastListener(Executor executor, OnTransactionBroadcastListener listener) {
|
||||
onTransactionEventListeners.add(new ListenerRegistration<OnTransactionBroadcastListener>(listener, executor));
|
||||
onTransactionEventListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/** Registers a listener that is called immediately before a message is received */
|
||||
@ -368,7 +368,7 @@ public class Peer extends PeerSocketHandler {
|
||||
|
||||
/** Registers a listener that is called immediately before a message is received */
|
||||
public void addPreMessageReceivedEventListener(Executor executor, PreMessageReceivedEventListener listener) {
|
||||
preMessageReceivedEventListeners.add(new ListenerRegistration<PreMessageReceivedEventListener>(listener, executor));
|
||||
preMessageReceivedEventListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
public boolean removeBlocksDownloadedEventListener(BlocksDownloadedEventListener listener) {
|
||||
@ -739,7 +739,7 @@ public class Peer extends PeerSocketHandler {
|
||||
|
||||
protected void processGetData(GetDataMessage getdata) {
|
||||
log.info("{}: Received getdata message: {}", getAddress(), getdata.toString());
|
||||
ArrayList<Message> items = new ArrayList<Message>();
|
||||
ArrayList<Message> items = new ArrayList<>();
|
||||
for (ListenerRegistration<GetDataEventListener> registration : getDataEventListeners) {
|
||||
if (registration.executor != Threading.SAME_THREAD) continue;
|
||||
List<Message> listenerItems = registration.listener.getData(this, getdata);
|
||||
@ -868,7 +868,7 @@ public class Peer extends PeerSocketHandler {
|
||||
TransactionConfidence.ConfidenceType txConfidence = tx.getConfidence().getConfidenceType();
|
||||
Preconditions.checkArgument(txConfidence != TransactionConfidence.ConfidenceType.BUILDING);
|
||||
log.info("{}: Downloading dependencies of {}", getAddress(), tx.getHashAsString());
|
||||
final LinkedList<Transaction> results = new LinkedList<Transaction>();
|
||||
final LinkedList<Transaction> results = new LinkedList<>();
|
||||
// future will be invoked when the entire dependency tree has been walked and the results compiled.
|
||||
final ListenableFuture<Object> future = downloadDependenciesInternal(vDownloadTxDependencyDepth, 0, tx,
|
||||
new Object(), results);
|
||||
@ -898,7 +898,7 @@ public class Peer extends PeerSocketHandler {
|
||||
// or depends on a no-fee transaction.
|
||||
|
||||
// We may end up requesting transactions that we've already downloaded and thrown away here.
|
||||
Set<Sha256Hash> needToRequest = new CopyOnWriteArraySet<Sha256Hash>();
|
||||
Set<Sha256Hash> needToRequest = new CopyOnWriteArraySet<>();
|
||||
for (TransactionInput input : tx.getInputs()) {
|
||||
// There may be multiple inputs that connect to the same transaction.
|
||||
needToRequest.add(input.getOutpoint().getHash());
|
||||
@ -1081,7 +1081,7 @@ public class Peer extends PeerSocketHandler {
|
||||
// that the new filter is now in use (which we have to simulate with a ping/pong), and then we can
|
||||
// safely restart the chain download with the new filter that contains a new set of lookahead keys.
|
||||
log.info("Bloom filter exhausted whilst processing block {}, discarding", m.getHash());
|
||||
awaitingFreshFilter = new LinkedList<Sha256Hash>();
|
||||
awaitingFreshFilter = new LinkedList<>();
|
||||
awaitingFreshFilter.add(m.getHash());
|
||||
awaitingFreshFilter.addAll(blockChain.drainOrphanBlocks());
|
||||
return; // Chain download process is restarted via a call to setBloomFilter.
|
||||
@ -1169,8 +1169,8 @@ public class Peer extends PeerSocketHandler {
|
||||
List<InventoryItem> items = inv.getItems();
|
||||
|
||||
// Separate out the blocks and transactions, we'll handle them differently
|
||||
List<InventoryItem> transactions = new LinkedList<InventoryItem>();
|
||||
List<InventoryItem> blocks = new LinkedList<InventoryItem>();
|
||||
List<InventoryItem> transactions = new LinkedList<>();
|
||||
List<InventoryItem> blocks = new LinkedList<>();
|
||||
|
||||
for (InventoryItem item : items) {
|
||||
switch (item.type) {
|
||||
@ -1427,7 +1427,7 @@ public class Peer extends PeerSocketHandler {
|
||||
// sends us the data we requested in a "headers" message.
|
||||
|
||||
// TODO: Block locators should be abstracted out rather than special cased here.
|
||||
List<Sha256Hash> blockLocator = new ArrayList<Sha256Hash>(51);
|
||||
List<Sha256Hash> blockLocator = new ArrayList<>(51);
|
||||
// For now we don't do the exponential thinning as suggested here:
|
||||
//
|
||||
// https://en.bitcoin.it/wiki/Protocol_specification#getblocks
|
||||
@ -1813,7 +1813,7 @@ public class Peer extends PeerSocketHandler {
|
||||
SettableFuture<UTXOsMessage> future = SettableFuture.create();
|
||||
// Add to the list of in flight requests.
|
||||
if (getutxoFutures == null)
|
||||
getutxoFutures = new LinkedList<SettableFuture<UTXOsMessage>>();
|
||||
getutxoFutures = new LinkedList<>();
|
||||
getutxoFutures.add(future);
|
||||
sendMessage(new GetUTXOsMessage(params, outPoints, includeMempool));
|
||||
return future;
|
||||
|
@ -115,25 +115,25 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
// Callback for events related to chain download.
|
||||
@Nullable @GuardedBy("lock") private PeerDataEventListener downloadListener;
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<BlocksDownloadedEventListener>> peersBlocksDownloadedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<BlocksDownloadedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<ChainDownloadStartedEventListener>> peersChainDownloadStartedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<ChainDownloadStartedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
/** Callbacks for events related to peers connecting */
|
||||
protected final CopyOnWriteArrayList<ListenerRegistration<PeerConnectedEventListener>> peerConnectedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PeerConnectedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
/** Callbacks for events related to peer connection/disconnection */
|
||||
protected final CopyOnWriteArrayList<ListenerRegistration<PeerDiscoveredEventListener>> peerDiscoveredEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PeerDiscoveredEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
/** Callbacks for events related to peers disconnecting */
|
||||
protected final CopyOnWriteArrayList<ListenerRegistration<PeerDisconnectedEventListener>> peerDisconnectedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PeerDisconnectedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
/** Callbacks for events related to peer data being received */
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<GetDataEventListener>> peerGetDataEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<GetDataEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<PreMessageReceivedEventListener>> peersPreMessageReceivedEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<PreMessageReceivedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
protected final CopyOnWriteArrayList<ListenerRegistration<OnTransactionBroadcastListener>> peersTransactionBroadastEventListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<OnTransactionBroadcastListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
// Peer discovery sources, will be polled occasionally if there aren't enough inactives.
|
||||
private final CopyOnWriteArraySet<PeerDiscovery> peerDiscoverers;
|
||||
// The version message to use for new connections.
|
||||
@ -323,8 +323,8 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
this.params = context.getParams();
|
||||
this.chain = chain;
|
||||
fastCatchupTimeSecs = params.getGenesisBlock().getTimeSeconds();
|
||||
wallets = new CopyOnWriteArrayList<Wallet>();
|
||||
peerFilterProviders = new CopyOnWriteArrayList<PeerFilterProvider>();
|
||||
wallets = new CopyOnWriteArrayList<>();
|
||||
peerFilterProviders = new CopyOnWriteArrayList<>();
|
||||
|
||||
executor = createPrivateExecutor();
|
||||
|
||||
@ -340,7 +340,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
downloadTxDependencyDepth = Integer.MAX_VALUE;
|
||||
|
||||
inactives = new PriorityQueue<PeerAddress>(1, new Comparator<PeerAddress>() {
|
||||
inactives = new PriorityQueue<>(1, new Comparator<PeerAddress>() {
|
||||
@SuppressWarnings("FieldAccessNotGuarded") // only called when inactives is accessed, and lock is held then.
|
||||
@Override
|
||||
public int compare(PeerAddress a, PeerAddress b) {
|
||||
@ -352,11 +352,11 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
backoffMap = new HashMap<PeerAddress, ExponentialBackoff>();
|
||||
peers = new CopyOnWriteArrayList<Peer>();
|
||||
pendingPeers = new CopyOnWriteArrayList<Peer>();
|
||||
backoffMap = new HashMap<>();
|
||||
peers = new CopyOnWriteArrayList<>();
|
||||
pendingPeers = new CopyOnWriteArrayList<>();
|
||||
channels = connectionManager;
|
||||
peerDiscoverers = new CopyOnWriteArraySet<PeerDiscovery>();
|
||||
peerDiscoverers = new CopyOnWriteArraySet<>();
|
||||
runningBroadcasts = Collections.synchronizedSet(new HashSet<TransactionBroadcast>());
|
||||
bloomFilterMerger = new FilterMerger(DEFAULT_BLOOM_FILTER_FP_RATE);
|
||||
vMinRequiredProtocolVersion = params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER);
|
||||
@ -539,8 +539,8 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
// Runs on peer threads.
|
||||
lock.lock();
|
||||
try {
|
||||
LinkedList<Message> transactions = new LinkedList<Message>();
|
||||
LinkedList<InventoryItem> items = new LinkedList<InventoryItem>(m.getItems());
|
||||
LinkedList<Message> transactions = new LinkedList<>();
|
||||
LinkedList<InventoryItem> items = new LinkedList<>(m.getItems());
|
||||
Iterator<InventoryItem> it = items.iterator();
|
||||
while (it.hasNext()) {
|
||||
InventoryItem item = it.next();
|
||||
@ -667,7 +667,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* @see Peer#addBlocksDownloadedEventListener(Executor, BlocksDownloadedEventListener)
|
||||
*/
|
||||
public void addBlocksDownloadedEventListener(Executor executor, BlocksDownloadedEventListener listener) {
|
||||
peersBlocksDownloadedEventListeners.add(new ListenerRegistration<BlocksDownloadedEventListener>(checkNotNull(listener), executor));
|
||||
peersBlocksDownloadedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addBlocksDownloadedEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -684,7 +684,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* chain download starts.</p>
|
||||
*/
|
||||
public void addChainDownloadStartedEventListener(Executor executor, ChainDownloadStartedEventListener listener) {
|
||||
peersChainDownloadStartedEventListeners.add(new ListenerRegistration<ChainDownloadStartedEventListener>(checkNotNull(listener), executor));
|
||||
peersChainDownloadStartedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addChainDownloadStartedEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -701,7 +701,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* new peers are connected to.</p>
|
||||
*/
|
||||
public void addConnectedEventListener(Executor executor, PeerConnectedEventListener listener) {
|
||||
peerConnectedEventListeners.add(new ListenerRegistration<PeerConnectedEventListener>(checkNotNull(listener), executor));
|
||||
peerConnectedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addConnectedEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -718,7 +718,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* peers are disconnected from.</p>
|
||||
*/
|
||||
public void addDisconnectedEventListener(Executor executor, PeerDisconnectedEventListener listener) {
|
||||
peerDisconnectedEventListeners.add(new ListenerRegistration<PeerDisconnectedEventListener>(checkNotNull(listener), executor));
|
||||
peerDisconnectedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addDisconnectedEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -735,7 +735,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* peers are discovered.</p>
|
||||
*/
|
||||
public void addDiscoveredEventListener(Executor executor, PeerDiscoveredEventListener listener) {
|
||||
peerDiscoveredEventListeners.add(new ListenerRegistration<PeerDiscoveredEventListener>(checkNotNull(listener), executor));
|
||||
peerDiscoveredEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
}
|
||||
|
||||
/** See {@link Peer#addGetDataEventListener(GetDataEventListener)} */
|
||||
@ -745,7 +745,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/** See {@link Peer#addGetDataEventListener(Executor, GetDataEventListener)} */
|
||||
public void addGetDataEventListener(final Executor executor, final GetDataEventListener listener) {
|
||||
peerGetDataEventListeners.add(new ListenerRegistration<GetDataEventListener>(checkNotNull(listener), executor));
|
||||
peerGetDataEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addGetDataEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -759,7 +759,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/** See {@link Peer#addOnTransactionBroadcastListener(OnTransactionBroadcastListener)} */
|
||||
public void addOnTransactionBroadcastListener(Executor executor, OnTransactionBroadcastListener listener) {
|
||||
peersTransactionBroadastEventListeners.add(new ListenerRegistration<OnTransactionBroadcastListener>(checkNotNull(listener), executor));
|
||||
peersTransactionBroadastEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addOnTransactionBroadcastListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -773,7 +773,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/** See {@link Peer#addPreMessageReceivedEventListener(Executor, PreMessageReceivedEventListener)} */
|
||||
public void addPreMessageReceivedEventListener(Executor executor, PreMessageReceivedEventListener listener) {
|
||||
peersPreMessageReceivedEventListeners.add(new ListenerRegistration<PreMessageReceivedEventListener>(checkNotNull(listener), executor));
|
||||
peersPreMessageReceivedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
|
||||
for (Peer peer : getConnectedPeers())
|
||||
peer.addPreMessageReceivedEventListener(executor, listener);
|
||||
for (Peer peer : getPendingPeers())
|
||||
@ -873,7 +873,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
public List<Peer> getConnectedPeers() {
|
||||
lock.lock();
|
||||
try {
|
||||
return new ArrayList<Peer>(peers);
|
||||
return new ArrayList<>(peers);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@ -885,7 +885,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
public List<Peer> getPendingPeers() {
|
||||
lock.lock();
|
||||
try {
|
||||
return new ArrayList<Peer>(pendingPeers);
|
||||
return new ArrayList<>(pendingPeers);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@ -2179,7 +2179,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
public static int getMostCommonChainHeight(final List<Peer> peers) {
|
||||
if (peers.isEmpty())
|
||||
return 0;
|
||||
List<Integer> heights = new ArrayList<Integer>(peers.size());
|
||||
List<Integer> heights = new ArrayList<>(peers.size());
|
||||
for (Peer peer : peers) heights.add((int) peer.getBestHeight());
|
||||
return Utils.maxOfMostFreq(heights);
|
||||
}
|
||||
@ -2198,7 +2198,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
return null;
|
||||
// Make sure we don't select a peer that is behind/synchronizing itself.
|
||||
int mostCommonChainHeight = getMostCommonChainHeight(peers);
|
||||
List<Peer> candidates = new ArrayList<Peer>();
|
||||
List<Peer> candidates = new ArrayList<>();
|
||||
for (Peer peer : peers) {
|
||||
if (peer.getBestHeight() == mostCommonChainHeight) candidates.add(peer);
|
||||
}
|
||||
@ -2213,7 +2213,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
highestVersion = Math.max(peer.getPeerVersionMessage().clientVersion, highestVersion);
|
||||
preferredVersion = Math.min(highestVersion, PREFERRED_VERSION);
|
||||
}
|
||||
ArrayList<Peer> candidates2 = new ArrayList<Peer>(candidates.size());
|
||||
ArrayList<Peer> candidates2 = new ArrayList<>(candidates.size());
|
||||
for (Peer peer : candidates) {
|
||||
if (peer.getPeerVersionMessage().clientVersion >= preferredVersion) {
|
||||
candidates2.add(peer);
|
||||
|
@ -190,8 +190,8 @@ public class Transaction extends ChildMessage {
|
||||
public Transaction(NetworkParameters params) {
|
||||
super(params);
|
||||
version = 1;
|
||||
inputs = new ArrayList<TransactionInput>();
|
||||
outputs = new ArrayList<TransactionOutput>();
|
||||
inputs = new ArrayList<>();
|
||||
outputs = new ArrayList<>();
|
||||
// We don't initialize appearsIn deliberately as it's only useful for transactions stored in the wallet.
|
||||
length = 8; // 8 for std fields
|
||||
}
|
||||
@ -340,7 +340,7 @@ public class Transaction extends ChildMessage {
|
||||
public void addBlockAppearance(final Sha256Hash blockHash, int relativityOffset) {
|
||||
if (appearsInHashes == null) {
|
||||
// TODO: This could be a lot more memory efficient as we'll typically only store one element.
|
||||
appearsInHashes = new TreeMap<Sha256Hash, Integer>();
|
||||
appearsInHashes = new TreeMap<>();
|
||||
}
|
||||
appearsInHashes.put(blockHash, relativityOffset);
|
||||
}
|
||||
@ -553,7 +553,7 @@ public class Transaction extends ChildMessage {
|
||||
// First come the inputs.
|
||||
long numInputs = readVarInt();
|
||||
optimalEncodingMessageSize += VarInt.sizeOf(numInputs);
|
||||
inputs = new ArrayList<TransactionInput>((int) numInputs);
|
||||
inputs = new ArrayList<>((int) numInputs);
|
||||
for (long i = 0; i < numInputs; i++) {
|
||||
TransactionInput input = new TransactionInput(params, this, payload, cursor, serializer);
|
||||
inputs.add(input);
|
||||
@ -564,7 +564,7 @@ public class Transaction extends ChildMessage {
|
||||
// Now the outputs
|
||||
long numOutputs = readVarInt();
|
||||
optimalEncodingMessageSize += VarInt.sizeOf(numOutputs);
|
||||
outputs = new ArrayList<TransactionOutput>((int) numOutputs);
|
||||
outputs = new ArrayList<>((int) numOutputs);
|
||||
for (long i = 0; i < numOutputs; i++) {
|
||||
TransactionOutput output = new TransactionOutput(params, this, payload, cursor, serializer);
|
||||
outputs.add(output);
|
||||
@ -1039,7 +1039,7 @@ public class Transaction extends ChildMessage {
|
||||
|
||||
if ((sigHashType & 0x1f) == SigHash.NONE.value) {
|
||||
// SIGHASH_NONE means no outputs are signed at all - the signature is effectively for a "blank cheque".
|
||||
tx.outputs = new ArrayList<TransactionOutput>(0);
|
||||
tx.outputs = new ArrayList<>(0);
|
||||
// The signature isn't broken by new versions of the transaction issued by other parties.
|
||||
for (int i = 0; i < tx.inputs.size(); i++)
|
||||
if (i != inputIndex)
|
||||
@ -1059,7 +1059,7 @@ public class Transaction extends ChildMessage {
|
||||
}
|
||||
// In SIGHASH_SINGLE the outputs after the matching input index are deleted, and the outputs before
|
||||
// that position are "nulled out". Unintuitively, the value in a "null" transaction is set to -1.
|
||||
tx.outputs = new ArrayList<TransactionOutput>(tx.outputs.subList(0, inputIndex + 1));
|
||||
tx.outputs = new ArrayList<>(tx.outputs.subList(0, inputIndex + 1));
|
||||
for (int i = 0; i < inputIndex; i++)
|
||||
tx.outputs.set(i, new TransactionOutput(tx.params, tx, Coin.NEGATIVE_SATOSHI, new byte[] {}));
|
||||
// The signature isn't broken by new versions of the transaction issued by other parties.
|
||||
@ -1162,7 +1162,7 @@ public class Transaction extends ChildMessage {
|
||||
* @return linked list of outputs relevant to the wallet in this transaction
|
||||
*/
|
||||
public List<TransactionOutput> getWalletOutputs(TransactionBag transactionBag){
|
||||
List<TransactionOutput> walletOutputs = new LinkedList<TransactionOutput>();
|
||||
List<TransactionOutput> walletOutputs = new LinkedList<>();
|
||||
for (TransactionOutput o : outputs) {
|
||||
if (!o.isMineOrWatched(transactionBag)) continue;
|
||||
walletOutputs.add(o);
|
||||
@ -1288,7 +1288,7 @@ public class Transaction extends ChildMessage {
|
||||
throw new VerificationException.LargerThanMaxBlockSize();
|
||||
|
||||
Coin valueOut = Coin.ZERO;
|
||||
HashSet<TransactionOutPoint> outpoints = new HashSet<TransactionOutPoint>();
|
||||
HashSet<TransactionOutPoint> outpoints = new HashSet<>();
|
||||
for (TransactionInput input : inputs) {
|
||||
if (outpoints.contains(input.getOutpoint()))
|
||||
throw new VerificationException.DuplicatedOutPoint();
|
||||
|
@ -145,8 +145,8 @@ public class TransactionConfidence {
|
||||
|
||||
public TransactionConfidence(Sha256Hash hash) {
|
||||
// Assume a default number of peers for our set.
|
||||
broadcastBy = new CopyOnWriteArrayList<PeerAddress>();
|
||||
listeners = new CopyOnWriteArrayList<ListenerRegistration<Listener>>();
|
||||
broadcastBy = new CopyOnWriteArrayList<>();
|
||||
listeners = new CopyOnWriteArrayList<>();
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public class TransactionConfidence {
|
||||
*/
|
||||
public void addEventListener(Executor executor, Listener listener) {
|
||||
checkNotNull(listener);
|
||||
listeners.addIfAbsent(new ListenerRegistration<Listener>(listener, executor));
|
||||
listeners.addIfAbsent(new ListenerRegistration<>(listener, executor));
|
||||
pinnedConfidenceObjects.add(this);
|
||||
}
|
||||
|
||||
|
@ -165,14 +165,14 @@ public class TransactionInput extends ChildMessage {
|
||||
Script script = scriptSig == null ? null : scriptSig.get();
|
||||
if (script == null) {
|
||||
script = new Script(scriptBytes);
|
||||
scriptSig = new WeakReference<Script>(script);
|
||||
scriptSig = new WeakReference<>(script);
|
||||
}
|
||||
return script;
|
||||
}
|
||||
|
||||
/** Set the given program as the scriptSig that is supposed to satisfy the connected output script. */
|
||||
public void setScriptSig(Script scriptSig) {
|
||||
this.scriptSig = new WeakReference<Script>(checkNotNull(scriptSig));
|
||||
this.scriptSig = new WeakReference<>(checkNotNull(scriptSig));
|
||||
// TODO: This should all be cleaned up so we have a consistent internal representation.
|
||||
setScriptBytes(scriptSig.getProgram());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class TransactionOutputChanges {
|
||||
((in.read() & 0xFF) << 8) |
|
||||
((in.read() & 0xFF) << 16) |
|
||||
((in.read() & 0xFF) << 24);
|
||||
txOutsCreated = new LinkedList<UTXO>();
|
||||
txOutsCreated = new LinkedList<>();
|
||||
for (int i = 0; i < numOutsCreated; i++)
|
||||
txOutsCreated.add(new UTXO(in));
|
||||
|
||||
@ -50,7 +50,7 @@ public class TransactionOutputChanges {
|
||||
((in.read() & 0xFF) << 8) |
|
||||
((in.read() & 0xFF) << 16) |
|
||||
((in.read() & 0xFF) << 24);
|
||||
txOutsSpent = new LinkedList<UTXO>();
|
||||
txOutsSpent = new LinkedList<>();
|
||||
for (int i = 0; i < numOutsSpent; i++)
|
||||
txOutsSpent.add(new UTXO(in));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class TxConfidenceTable {
|
||||
return size() > size;
|
||||
}
|
||||
};
|
||||
referenceQueue = new ReferenceQueue<TransactionConfidence>();
|
||||
referenceQueue = new ReferenceQueue<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ public class UTXOsMessage extends Message {
|
||||
if (outputs.get(i) != null)
|
||||
Utils.setBitLE(hits, i);
|
||||
}
|
||||
this.outputs = new ArrayList<TransactionOutput>(outputs.size());
|
||||
this.outputs = new ArrayList<>(outputs.size());
|
||||
for (TransactionOutput output : outputs) {
|
||||
if (output != null) this.outputs.add(output);
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class UTXOsMessage extends Message {
|
||||
int numOuts = (int) readVarInt();
|
||||
if (numOuts < 0 || numOuts > InventoryMessage.MAX_INVENTORY_ITEMS)
|
||||
throw new ProtocolException("numOuts out of range: " + numOuts);
|
||||
outputs = new ArrayList<TransactionOutput>(numOuts);
|
||||
outputs = new ArrayList<>(numOuts);
|
||||
heights = new long[numOuts];
|
||||
for (int i = 0; i < numOuts; i++) {
|
||||
long version = readUint32();
|
||||
@ -135,7 +135,7 @@ public class UTXOsMessage extends Message {
|
||||
|
||||
/** Returns the list of outputs that matched the query. */
|
||||
public List<TransactionOutput> getOutputs() {
|
||||
return new ArrayList<TransactionOutput>(outputs);
|
||||
return new ArrayList<>(outputs);
|
||||
}
|
||||
|
||||
/** Returns the block heights of each output returned in getOutputs(), or MEMPOOL_HEIGHT if not confirmed yet. */
|
||||
|
@ -552,7 +552,7 @@ public class Utils {
|
||||
/** Enable or disable mock sleep. If enabled, set mock time to current time. */
|
||||
public static void setMockSleep(boolean isEnable) {
|
||||
if (isEnable) {
|
||||
mockSleepQueue = new ArrayBlockingQueue<Boolean>(1);
|
||||
mockSleepQueue = new ArrayBlockingQueue<>(1);
|
||||
mockTime = new Date(System.currentTimeMillis());
|
||||
} else {
|
||||
mockSleepQueue = null;
|
||||
@ -589,7 +589,7 @@ public class Utils {
|
||||
|
||||
public static int maxOfMostFreq(int... items) {
|
||||
// Java 6 sucks.
|
||||
ArrayList<Integer> list = new ArrayList<Integer>(items.length);
|
||||
ArrayList<Integer> list = new ArrayList<>(items.length);
|
||||
for (int item : items) list.add(item);
|
||||
return maxOfMostFreq(list);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public final class HDUtils {
|
||||
*/
|
||||
public static List<ChildNumber> parsePath(@Nonnull String path) {
|
||||
String[] parsedNodes = path.replace("M", "").split("/");
|
||||
List<ChildNumber> nodes = new ArrayList<ChildNumber>();
|
||||
List<ChildNumber> nodes = new ArrayList<>();
|
||||
|
||||
for (String n : parsedNodes) {
|
||||
n = n.replaceAll(" ", "");
|
||||
|
@ -87,7 +87,7 @@ public class MnemonicCode {
|
||||
*/
|
||||
public MnemonicCode(InputStream wordstream, String wordListDigest) throws IOException, IllegalArgumentException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(wordstream, "UTF-8"));
|
||||
this.wordList = new ArrayList<String>(2048);
|
||||
this.wordList = new ArrayList<>(2048);
|
||||
MessageDigest md = Sha256Hash.newDigest();
|
||||
String word;
|
||||
while ((word = br.readLine()) != null) {
|
||||
@ -216,7 +216,7 @@ public class MnemonicCode {
|
||||
// which is a position in a wordlist. We convert numbers into
|
||||
// words and use joined words as mnemonic sentence.
|
||||
|
||||
ArrayList<String> words = new ArrayList<String>();
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
int nwords = concatBits.length / 11;
|
||||
for (int i = 0; i < nwords; ++i) {
|
||||
int index = 0;
|
||||
|
@ -61,7 +61,7 @@ class ConnectionHandler implements MessageWriteTarget {
|
||||
@GuardedBy("lock") private boolean closeCalled = false;
|
||||
|
||||
@GuardedBy("lock") private long bytesToWriteRemaining = 0;
|
||||
@GuardedBy("lock") private final LinkedList<ByteBuffer> bytesToWrite = new LinkedList<ByteBuffer>();
|
||||
@GuardedBy("lock") private final LinkedList<ByteBuffer> bytesToWrite = new LinkedList<>();
|
||||
|
||||
private Set<ConnectionHandler> connectedHandlers;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class NioClientManager extends AbstractExecutionThreadService implements
|
||||
|
||||
PendingConnect(SocketChannel sc, StreamConnection connection, SocketAddress address) { this.sc = sc; this.connection = connection; this.address = address; }
|
||||
}
|
||||
final Queue<PendingConnect> newConnectionChannels = new LinkedBlockingQueue<PendingConnect>();
|
||||
final Queue<PendingConnect> newConnectionChannels = new LinkedBlockingQueue<>();
|
||||
|
||||
// Added to/removed from by the individual ConnectionHandler's, thus must by synchronized on its own.
|
||||
private final Set<ConnectionHandler> connectedHandlers = Collections.synchronizedSet(new HashSet<ConnectionHandler>());
|
||||
|
@ -77,7 +77,7 @@ public class ProtobufConnection<MessageType extends MessageLite> extends Abstrac
|
||||
@GuardedBy("lock") private byte[] messageBytes;
|
||||
private final ReentrantLock lock = Threading.lock("ProtobufConnection");
|
||||
|
||||
@VisibleForTesting final AtomicReference<MessageWriteTarget> writeTarget = new AtomicReference<MessageWriteTarget>();
|
||||
@VisibleForTesting final AtomicReference<MessageWriteTarget> writeTarget = new AtomicReference<>();
|
||||
|
||||
/**
|
||||
* Creates a new protobuf handler.
|
||||
|
@ -56,7 +56,7 @@ public class DnsDiscovery extends MultiplexingDiscovery {
|
||||
}
|
||||
|
||||
private static List<PeerDiscovery> buildDiscoveries(NetworkParameters params, String[] seeds) {
|
||||
List<PeerDiscovery> discoveries = new ArrayList<PeerDiscovery>();
|
||||
List<PeerDiscovery> discoveries = new ArrayList<>();
|
||||
if (seeds != null)
|
||||
for (String seed : seeds)
|
||||
discoveries.add(new DnsSeedDiscovery(params, seed));
|
||||
|
@ -103,7 +103,7 @@ public abstract class PaymentChannelClientState {
|
||||
protected StoredClientChannel storedChannel;
|
||||
|
||||
PaymentChannelClientState(StoredClientChannel storedClientChannel, Wallet wallet) throws VerificationException {
|
||||
this.stateMachine = new StateMachine<State>(State.UNINITIALISED, getStateTransitions());
|
||||
this.stateMachine = new StateMachine<>(State.UNINITIALISED, getStateTransitions());
|
||||
this.wallet = checkNotNull(wallet);
|
||||
this.myKey = checkNotNull(storedClientChannel.myKey);
|
||||
this.serverKey = checkNotNull(storedClientChannel.serverKey);
|
||||
@ -140,7 +140,7 @@ public abstract class PaymentChannelClientState {
|
||||
*/
|
||||
public PaymentChannelClientState(Wallet wallet, ECKey myKey, ECKey serverKey,
|
||||
Coin value, long expiryTimeInSeconds) throws VerificationException {
|
||||
this.stateMachine = new StateMachine<State>(State.UNINITIALISED, getStateTransitions());
|
||||
this.stateMachine = new StateMachine<>(State.UNINITIALISED, getStateTransitions());
|
||||
this.wallet = checkNotNull(wallet);
|
||||
this.serverKey = checkNotNull(serverKey);
|
||||
this.myKey = checkNotNull(myKey);
|
||||
|
@ -117,7 +117,7 @@ public abstract class PaymentChannelServerState {
|
||||
|
||||
PaymentChannelServerState(StoredServerChannel storedServerChannel, Wallet wallet, TransactionBroadcaster broadcaster) throws VerificationException {
|
||||
synchronized (storedServerChannel) {
|
||||
this.stateMachine = new StateMachine<State>(State.UNINITIALISED, getStateTransitions());
|
||||
this.stateMachine = new StateMachine<>(State.UNINITIALISED, getStateTransitions());
|
||||
this.wallet = checkNotNull(wallet);
|
||||
this.broadcaster = checkNotNull(broadcaster);
|
||||
this.contract = checkNotNull(storedServerChannel.contract);
|
||||
@ -141,7 +141,7 @@ public abstract class PaymentChannelServerState {
|
||||
* @param minExpireTime The earliest time at which the client can claim the refund transaction (UNIX timestamp of block)
|
||||
*/
|
||||
public PaymentChannelServerState(TransactionBroadcaster broadcaster, Wallet wallet, ECKey serverKey, long minExpireTime) {
|
||||
this.stateMachine = new StateMachine<State>(State.UNINITIALISED, getStateTransitions());
|
||||
this.stateMachine = new StateMachine<>(State.UNINITIALISED, getStateTransitions());
|
||||
this.serverKey = checkNotNull(serverKey);
|
||||
this.wallet = checkNotNull(wallet);
|
||||
this.broadcaster = checkNotNull(broadcaster);
|
||||
|
@ -47,7 +47,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
|
||||
static final String EXTENSION_ID = StoredPaymentChannelServerStates.class.getName();
|
||||
static final int MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET = 10;
|
||||
|
||||
@GuardedBy("lock") @VisibleForTesting final Map<Sha256Hash, StoredServerChannel> mapChannels = new HashMap<Sha256Hash, StoredServerChannel>();
|
||||
@GuardedBy("lock") @VisibleForTesting final Map<Sha256Hash, StoredServerChannel> mapChannels = new HashMap<>();
|
||||
private Wallet wallet;
|
||||
private final SettableFuture<TransactionBroadcaster> broadcasterFuture = SettableFuture.create();
|
||||
|
||||
|
@ -340,7 +340,7 @@ public class PaymentProtocol {
|
||||
*/
|
||||
public static List<Transaction> parseTransactionsFromPaymentMessage(NetworkParameters params,
|
||||
Protos.Payment paymentMessage) {
|
||||
final List<Transaction> transactions = new ArrayList<Transaction>(paymentMessage.getTransactionsCount());
|
||||
final List<Transaction> transactions = new ArrayList<>(paymentMessage.getTransactionsCount());
|
||||
for (final ByteString transaction : paymentMessage.getTransactionsList())
|
||||
transactions.add(params.getDefaultSerializer().makeTransaction(transaction.toByteArray()));
|
||||
return transactions;
|
||||
|
@ -224,7 +224,7 @@ public class PaymentSession {
|
||||
* Returns the outputs of the payment request.
|
||||
*/
|
||||
public List<PaymentProtocol.Output> getOutputs() {
|
||||
List<PaymentProtocol.Output> outputs = new ArrayList<PaymentProtocol.Output>(paymentDetails.getOutputsCount());
|
||||
List<PaymentProtocol.Output> outputs = new ArrayList<>(paymentDetails.getOutputsCount());
|
||||
for (Protos.Output output : paymentDetails.getOutputsList()) {
|
||||
Coin amount = output.hasAmount() ? Coin.valueOf(output.getAmount()) : null;
|
||||
outputs.add(new PaymentProtocol.Output(amount, output.getScript().toByteArray()));
|
||||
|
@ -101,7 +101,7 @@ public class Script {
|
||||
|
||||
// Used from ScriptBuilder.
|
||||
Script(List<ScriptChunk> chunks) {
|
||||
this.chunks = Collections.unmodifiableList(new ArrayList<ScriptChunk>(chunks));
|
||||
this.chunks = Collections.unmodifiableList(new ArrayList<>(chunks));
|
||||
creationTimeSeconds = Utils.currentTimeSeconds();
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class Script {
|
||||
* Bitcoin Core does something similar.</p>
|
||||
*/
|
||||
private void parse(byte[] program) throws ScriptException {
|
||||
chunks = new ArrayList<ScriptChunk>(5); // Common size.
|
||||
chunks = new ArrayList<>(5); // Common size.
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(program);
|
||||
int initialSize = bis.available();
|
||||
while (bis.available() > 0) {
|
||||
@ -864,8 +864,8 @@ public class Script {
|
||||
int opCount = 0;
|
||||
int lastCodeSepLocation = 0;
|
||||
|
||||
LinkedList<byte[]> altstack = new LinkedList<byte[]>();
|
||||
LinkedList<Boolean> ifStack = new LinkedList<Boolean>();
|
||||
LinkedList<byte[]> altstack = new LinkedList<>();
|
||||
LinkedList<Boolean> ifStack = new LinkedList<>();
|
||||
|
||||
for (ScriptChunk chunk : script.chunks) {
|
||||
boolean shouldExecute = !ifStack.contains(false);
|
||||
@ -1487,7 +1487,7 @@ public class Script {
|
||||
if (stack.size() < pubKeyCount + 1)
|
||||
throw new ScriptException("Attempted OP_CHECKMULTISIG(VERIFY) on a stack with size < num_of_pubkeys + 2");
|
||||
|
||||
LinkedList<byte[]> pubkeys = new LinkedList<byte[]>();
|
||||
LinkedList<byte[]> pubkeys = new LinkedList<>();
|
||||
for (int i = 0; i < pubKeyCount; i++) {
|
||||
byte[] pubKey = stack.pollLast();
|
||||
pubkeys.add(pubKey);
|
||||
@ -1499,7 +1499,7 @@ public class Script {
|
||||
if (stack.size() < sigCount + 1)
|
||||
throw new ScriptException("Attempted OP_CHECKMULTISIG(VERIFY) on a stack with size < num_of_pubkeys + num_of_signatures + 3");
|
||||
|
||||
LinkedList<byte[]> sigs = new LinkedList<byte[]>();
|
||||
LinkedList<byte[]> sigs = new LinkedList<>();
|
||||
for (int i = 0; i < sigCount; i++) {
|
||||
byte[] sig = stack.pollLast();
|
||||
sigs.add(sig);
|
||||
@ -1591,12 +1591,12 @@ public class Script {
|
||||
if (getProgram().length > 10000 || scriptPubKey.getProgram().length > 10000)
|
||||
throw new ScriptException("Script larger than 10,000 bytes");
|
||||
|
||||
LinkedList<byte[]> stack = new LinkedList<byte[]>();
|
||||
LinkedList<byte[]> stack = new LinkedList<>();
|
||||
LinkedList<byte[]> p2shStack = null;
|
||||
|
||||
executeScript(txContainingThis, scriptSigIndex, this, stack, verifyFlags);
|
||||
if (verifyFlags.contains(VerifyFlag.P2SH))
|
||||
p2shStack = new LinkedList<byte[]>(stack);
|
||||
p2shStack = new LinkedList<>(stack);
|
||||
executeScript(txContainingThis, scriptSigIndex, scriptPubKey, stack, verifyFlags);
|
||||
|
||||
if (stack.size() == 0)
|
||||
|
@ -49,7 +49,7 @@ public class ScriptBuilder {
|
||||
|
||||
/** Creates a fresh ScriptBuilder with the given program as the starting point. */
|
||||
public ScriptBuilder(Script template) {
|
||||
chunks = new ArrayList<ScriptChunk>(template.getChunks());
|
||||
chunks = new ArrayList<>(template.getChunks());
|
||||
}
|
||||
|
||||
/** Adds the given chunk to the end of the program */
|
||||
@ -178,7 +178,7 @@ public class ScriptBuilder {
|
||||
if (num == 0) {
|
||||
data = new byte[0];
|
||||
} else {
|
||||
Stack<Byte> result = new Stack<Byte>();
|
||||
Stack<Byte> result = new Stack<>();
|
||||
final boolean neg = num < 0;
|
||||
long absvalue = Math.abs(num);
|
||||
|
||||
@ -276,7 +276,7 @@ public class ScriptBuilder {
|
||||
|
||||
/** Create a program that satisfies an OP_CHECKMULTISIG program. */
|
||||
public static Script createMultiSigInputScript(List<TransactionSignature> signatures) {
|
||||
List<byte[]> sigs = new ArrayList<byte[]>(signatures.size());
|
||||
List<byte[]> sigs = new ArrayList<>(signatures.size());
|
||||
for (TransactionSignature signature : signatures) {
|
||||
sigs.add(signature.encodeToBitcoin());
|
||||
}
|
||||
@ -300,7 +300,7 @@ public class ScriptBuilder {
|
||||
*/
|
||||
public static Script createP2SHMultiSigInputScript(@Nullable List<TransactionSignature> signatures,
|
||||
Script multisigProgram) {
|
||||
List<byte[]> sigs = new ArrayList<byte[]>();
|
||||
List<byte[]> sigs = new ArrayList<>();
|
||||
if (signatures == null) {
|
||||
// create correct number of empty signatures
|
||||
int numSigs = multisigProgram.getNumberOfSignaturesRequiredToSpend();
|
||||
@ -422,7 +422,7 @@ public class ScriptBuilder {
|
||||
* redeem script in the lexicographical sorting order.
|
||||
*/
|
||||
public static Script createRedeemScript(int threshold, List<ECKey> pubkeys) {
|
||||
pubkeys = new ArrayList<ECKey>(pubkeys);
|
||||
pubkeys = new ArrayList<>(pubkeys);
|
||||
Collections.sort(pubkeys, ECKey.PUBKEY_COMPARATOR);
|
||||
return ScriptBuilder.createMultiSigOutputScript(threshold, pubkeys);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public interface TransactionSigner {
|
||||
|
||||
public ProposedTransaction(Transaction partialTx) {
|
||||
this.partialTx = partialTx;
|
||||
this.keyPaths = new HashMap<Script, List<ChildNumber>>();
|
||||
this.keyPaths = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,8 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
this.schemaName = schemaName;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.conn = new ThreadLocal<Connection>();
|
||||
this.allConnections = new LinkedList<Connection>();
|
||||
this.conn = new ThreadLocal<>();
|
||||
this.allConnections = new LinkedList<>();
|
||||
|
||||
try {
|
||||
Class.forName(getDatabaseDriverClass());
|
||||
@ -246,7 +246,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
* @return The SQL prepared statements.
|
||||
*/
|
||||
protected List<String> getCompatibilitySQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(SELECT_COMPATIBILITY_COINBASE_SQL);
|
||||
return sqlStatements;
|
||||
}
|
||||
@ -264,7 +264,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
* @return The SQL drop statements.
|
||||
*/
|
||||
protected List<String> getDropTablesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(DROP_SETTINGS_TABLE);
|
||||
sqlStatements.add(DROP_HEADERS_TABLE);
|
||||
sqlStatements.add(DROP_UNDOABLE_TABLE);
|
||||
@ -810,7 +810,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
((transactions[offset++] & 0xFF) << 8) |
|
||||
((transactions[offset++] & 0xFF) << 16) |
|
||||
((transactions[offset++] & 0xFF) << 24);
|
||||
List<Transaction> transactionList = new LinkedList<Transaction>();
|
||||
List<Transaction> transactionList = new LinkedList<>();
|
||||
for (int i = 0; i < numTxn; i++) {
|
||||
Transaction tx = params.getDefaultSerializer().makeTransaction(transactions, offset);
|
||||
transactionList.add(tx);
|
||||
@ -1158,7 +1158,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
@Override
|
||||
public List<UTXO> getOpenTransactionOutputs(List<Address> addresses) throws UTXOProviderException {
|
||||
PreparedStatement s = null;
|
||||
List<UTXO> outputs = new ArrayList<UTXO>();
|
||||
List<UTXO> outputs = new ArrayList<>();
|
||||
try {
|
||||
maybeConnect();
|
||||
s = conn.get().prepareStatement(getTransactionOutputSelectSQL());
|
||||
|
@ -133,7 +133,7 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateTablesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_SETTINGS_TABLE);
|
||||
sqlStatements.add(CREATE_HEADERS_TABLE);
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE);
|
||||
@ -143,7 +143,7 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateIndexesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESS_MULTI_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX);
|
||||
|
@ -259,9 +259,9 @@ public class LevelDBFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
fullStoreDepth = blockCount;
|
||||
this.instrument = instrument;
|
||||
this.exitBlock = exitBlock;
|
||||
methodStartTime = new HashMap<String, Stopwatch>();
|
||||
methodCalls = new HashMap<String, Long>();
|
||||
methodTotalTime = new HashMap<String, Long>();
|
||||
methodStartTime = new HashMap<>();
|
||||
methodCalls = new HashMap<>();
|
||||
methodTotalTime = new HashMap<>();
|
||||
|
||||
this.filename = filename;
|
||||
this.leveldbReadCache = leveldbReadCache;
|
||||
@ -424,7 +424,7 @@ public class LevelDBFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
// This is critical or if one address paid another could get incorrect
|
||||
// results
|
||||
|
||||
List<UTXO> results = new LinkedList<UTXO>();
|
||||
List<UTXO> results = new LinkedList<>();
|
||||
for (Address a : addresses) {
|
||||
ByteBuffer bb = ByteBuffer.allocate(21);
|
||||
bb.put((byte) KeyType.ADDRESS_HASHINDEX.ordinal());
|
||||
@ -674,7 +674,7 @@ public class LevelDBFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
int offset = 0;
|
||||
int numTxn = ((transactions[offset++] & 0xFF) << 0) | ((transactions[offset++] & 0xFF) << 8)
|
||||
| ((transactions[offset++] & 0xFF) << 16) | ((transactions[offset++] & 0xFF) << 24);
|
||||
List<Transaction> transactionList = new LinkedList<Transaction>();
|
||||
List<Transaction> transactionList = new LinkedList<>();
|
||||
for (int i = 0; i < numTxn; i++) {
|
||||
Transaction tx = new Transaction(params, transactions, offset);
|
||||
transactionList.add(tx);
|
||||
@ -1039,10 +1039,10 @@ public class LevelDBFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
beginMethod("beginDatabaseBatchWrite");
|
||||
|
||||
batch = db.createWriteBatch();
|
||||
uncommited = new HashMap<ByteBuffer, byte[]>();
|
||||
uncommitedDeletes = new HashSet<ByteBuffer>();
|
||||
utxoUncommittedCache = new HashMap<ByteBuffer, UTXO>();
|
||||
utxoUncommittedDeletedCache = new HashSet<ByteBuffer>();
|
||||
uncommited = new HashMap<>();
|
||||
uncommitedDeletes = new HashSet<>();
|
||||
utxoUncommittedCache = new HashMap<>();
|
||||
utxoUncommittedDeletedCache = new HashSet<>();
|
||||
autoCommit = false;
|
||||
if (instrument)
|
||||
endMethod("beginDatabaseBatchWrite");
|
||||
|
@ -90,10 +90,10 @@ class TransactionalHashMap<KeyType, ValueType> {
|
||||
HashMap<KeyType, ValueType> map;
|
||||
|
||||
public TransactionalHashMap() {
|
||||
tempMap = new ThreadLocal<HashMap<KeyType, ValueType>>();
|
||||
tempSetRemoved = new ThreadLocal<HashSet<KeyType>>();
|
||||
inTransaction = new ThreadLocal<Boolean>();
|
||||
map = new HashMap<KeyType, ValueType>();
|
||||
tempMap = new ThreadLocal<>();
|
||||
tempSetRemoved = new ThreadLocal<>();
|
||||
inTransaction = new ThreadLocal<>();
|
||||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
public void beginDatabaseBatchWrite() {
|
||||
@ -131,7 +131,7 @@ class TransactionalHashMap<KeyType, ValueType> {
|
||||
}
|
||||
|
||||
public List<ValueType> values() {
|
||||
List<ValueType> valueTypes = new ArrayList<ValueType>();
|
||||
List<ValueType> valueTypes = new ArrayList<>();
|
||||
for (KeyType keyType : map.keySet()) {
|
||||
valueTypes.add(get(keyType));
|
||||
}
|
||||
@ -182,8 +182,8 @@ class TransactionalMultiKeyHashMap<UniqueKeyType, MultiKeyType, ValueType> {
|
||||
HashMap<MultiKeyType, Set<UniqueKeyType>> mapKeys;
|
||||
|
||||
public TransactionalMultiKeyHashMap() {
|
||||
mapValues = new TransactionalHashMap<UniqueKeyType, ValueType>();
|
||||
mapKeys = new HashMap<MultiKeyType, Set<UniqueKeyType>>();
|
||||
mapValues = new TransactionalHashMap<>();
|
||||
mapKeys = new HashMap<>();
|
||||
}
|
||||
|
||||
public void BeginTransaction() {
|
||||
@ -207,7 +207,7 @@ class TransactionalMultiKeyHashMap<UniqueKeyType, MultiKeyType, ValueType> {
|
||||
mapValues.put(uniqueKey, value);
|
||||
Set<UniqueKeyType> set = mapKeys.get(multiKey);
|
||||
if (set == null) {
|
||||
set = new HashSet<UniqueKeyType>();
|
||||
set = new HashSet<>();
|
||||
set.add(uniqueKey);
|
||||
mapKeys.put(multiKey, set);
|
||||
}else{
|
||||
@ -253,9 +253,9 @@ public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
* @param fullStoreDepth The depth of blocks to keep FullStoredBlocks instead of StoredBlocks
|
||||
*/
|
||||
public MemoryFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth) {
|
||||
blockMap = new TransactionalHashMap<Sha256Hash, StoredBlockAndWasUndoableFlag>();
|
||||
fullBlockMap = new TransactionalMultiKeyHashMap<Sha256Hash, Integer, StoredUndoableBlock>();
|
||||
transactionOutputMap = new TransactionalHashMap<StoredTransactionOutPoint, UTXO>();
|
||||
blockMap = new TransactionalHashMap<>();
|
||||
fullBlockMap = new TransactionalMultiKeyHashMap<>();
|
||||
transactionOutputMap = new TransactionalHashMap<>();
|
||||
this.fullStoreDepth = fullStoreDepth > 0 ? fullStoreDepth : 1;
|
||||
// Insert the genesis block.
|
||||
try {
|
||||
@ -415,7 +415,7 @@ public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
public List<UTXO> getOpenTransactionOutputs(List<Address> addresses) throws UTXOProviderException {
|
||||
// This is *NOT* optimal: We go through all the outputs and select the ones we are looking for.
|
||||
// If someone uses this store for production then they have a lot more to worry about than an inefficient impl :)
|
||||
List<UTXO> foundOutputs = new ArrayList<UTXO>();
|
||||
List<UTXO> foundOutputs = new ArrayList<>();
|
||||
List<UTXO> outputsList = transactionOutputMap.values();
|
||||
for (UTXO output : outputsList) {
|
||||
for (Address address : addresses) {
|
||||
|
@ -125,7 +125,7 @@ public class MySQLFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateTablesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_SETTINGS_TABLE);
|
||||
sqlStatements.add(CREATE_HEADERS_TABLE);
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE);
|
||||
@ -135,7 +135,7 @@ public class MySQLFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateIndexesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESS_MULTI_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX);
|
||||
|
@ -133,7 +133,7 @@ public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateTablesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_SETTINGS_TABLE);
|
||||
sqlStatements.add(CREATE_HEADERS_TABLE);
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE);
|
||||
@ -143,7 +143,7 @@ public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateIndexesSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add(CREATE_UNDOABLE_TABLE_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESS_MULTI_INDEX);
|
||||
sqlStatements.add(CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX);
|
||||
@ -154,7 +154,7 @@ public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
||||
@Override
|
||||
protected List<String> getCreateSchemeSQL() {
|
||||
List<String> sqlStatements = new ArrayList<String>();
|
||||
List<String> sqlStatements = new ArrayList<>();
|
||||
sqlStatements.add("CREATE SCHEMA IF NOT EXISTS " + schemaName);
|
||||
sqlStatements.add("set search_path to '" + schemaName +"'");
|
||||
return sqlStatements;
|
||||
|
@ -98,7 +98,7 @@ public class BitcoinURI {
|
||||
/**
|
||||
* Contains all the parameters in the order in which they were processed
|
||||
*/
|
||||
private final Map<String, Object> parameterMap = new LinkedHashMap<String, Object>();
|
||||
private final Map<String, Object> parameterMap = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new BitcoinURI from the given string. Can be for any network.
|
||||
@ -299,7 +299,7 @@ public class BitcoinURI {
|
||||
* all subsequent URLs are fallbacks.
|
||||
*/
|
||||
public List<String> getPaymentRequestUrls() {
|
||||
ArrayList<String> urls = new ArrayList<String>();
|
||||
ArrayList<String> urls = new ArrayList<>();
|
||||
while (true) {
|
||||
int i = urls.size();
|
||||
String paramName = FIELD_PAYMENT_REQUEST_URL + (i > 0 ? Integer.toString(i) : "");
|
||||
|
@ -57,7 +57,7 @@ public class BaseTaggableObject implements TaggableObject {
|
||||
checkNotNull(tag);
|
||||
checkNotNull(value);
|
||||
if (tags == null)
|
||||
tags = new HashMap<String, ByteString>();
|
||||
tags = new HashMap<>();
|
||||
tags.put(tag, value);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class BlockFileLoader implements Iterable<Block>, Iterator<Block> {
|
||||
defaultDataDir = System.getProperty("user.home") + "/.bitcoin/blocks/";
|
||||
}
|
||||
|
||||
List<File> list = new LinkedList<File>();
|
||||
List<File> list = new LinkedList<>();
|
||||
for (int i = 0; true; i++) {
|
||||
File file = new File(defaultDataDir + String.format(Locale.US, "blk%05d.dat", i));
|
||||
if (!file.exists())
|
||||
|
@ -923,7 +923,7 @@ public abstract class BtcFormat extends Format {
|
||||
public static BtcFormat getCoinInstance() { return getCoinInstance(defaultLocale()); }
|
||||
|
||||
private static List<Integer> boxAsList(int[] elements) throws IllegalArgumentException {
|
||||
List<Integer> list = new ArrayList<Integer>(elements.length);
|
||||
List<Integer> list = new ArrayList<>(elements.length);
|
||||
for (int e : elements) {
|
||||
checkArgument(e > 0, "Size of decimal group must be at least one.");
|
||||
list.add(e);
|
||||
|
@ -157,7 +157,7 @@ public final class MonetaryFormat {
|
||||
* any number numbers of decimals, one for each group
|
||||
*/
|
||||
public MonetaryFormat optionalDecimals(int... groups) {
|
||||
List<Integer> decimalGroups = new ArrayList<Integer>(groups.length);
|
||||
List<Integer> decimalGroups = new ArrayList<>(groups.length);
|
||||
for (int group : groups)
|
||||
decimalGroups.add(group);
|
||||
return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups,
|
||||
@ -183,7 +183,7 @@ public final class MonetaryFormat {
|
||||
*/
|
||||
public MonetaryFormat repeatOptionalDecimals(int decimals, int repetitions) {
|
||||
checkArgument(repetitions >= 0);
|
||||
List<Integer> decimalGroups = new ArrayList<Integer>(repetitions);
|
||||
List<Integer> decimalGroups = new ArrayList<>(repetitions);
|
||||
for (int i = 0; i < repetitions; i++)
|
||||
decimalGroups.add(decimals);
|
||||
return new MonetaryFormat(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups,
|
||||
|
@ -95,7 +95,7 @@ public class Threading {
|
||||
public UserThread() {
|
||||
super("bitcoinj user thread");
|
||||
setDaemon(true);
|
||||
tasks = new LinkedBlockingQueue<Runnable>();
|
||||
tasks = new LinkedBlockingQueue<>();
|
||||
start();
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class VersionTally {
|
||||
public void initialize(final BlockStore blockStore, final StoredBlock chainHead)
|
||||
throws BlockStoreException {
|
||||
StoredBlock versionBlock = chainHead;
|
||||
final Stack<Long> versions = new Stack<Long>();
|
||||
final Stack<Long> versions = new Stack<>();
|
||||
|
||||
// We don't know how many blocks back we can go, so load what we can first
|
||||
versions.push(versionBlock.getHeader().getVersion());
|
||||
|
@ -58,9 +58,9 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
|
||||
public BasicKeyChain(@Nullable KeyCrypter crypter) {
|
||||
this.keyCrypter = crypter;
|
||||
hashToKeys = new LinkedHashMap<ByteString, ECKey>();
|
||||
pubkeyToKeys = new LinkedHashMap<ByteString, ECKey>();
|
||||
listeners = new CopyOnWriteArrayList<ListenerRegistration<KeyChainEventListener>>();
|
||||
hashToKeys = new LinkedHashMap<>();
|
||||
pubkeyToKeys = new LinkedHashMap<>();
|
||||
listeners = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
/** Returns the {@link KeyCrypter} in use or null if the key chain is not encrypted. */
|
||||
@ -99,7 +99,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
if (hashToKeys.size() < numberOfKeys) {
|
||||
checkState(keyCrypter == null);
|
||||
|
||||
List<ECKey> keys = new ArrayList<ECKey>();
|
||||
List<ECKey> keys = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfKeys - hashToKeys.size(); i++) {
|
||||
keys.add(new ECKey());
|
||||
}
|
||||
@ -109,7 +109,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
queueOnKeysAdded(immutableKeys);
|
||||
}
|
||||
|
||||
List<ECKey> keysToReturn = new ArrayList<ECKey>();
|
||||
List<ECKey> keysToReturn = new ArrayList<>();
|
||||
int count = 0;
|
||||
while (hashToKeys.values().iterator().hasNext() && numberOfKeys != count) {
|
||||
keysToReturn.add(hashToKeys.values().iterator().next());
|
||||
@ -125,7 +125,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
public List<ECKey> getKeys() {
|
||||
lock.lock();
|
||||
try {
|
||||
return new ArrayList<ECKey>(hashToKeys.values());
|
||||
return new ArrayList<>(hashToKeys.values());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
for (ECKey key : keys) {
|
||||
checkKeyEncryptionStateMatches(key);
|
||||
}
|
||||
List<ECKey> actuallyAdded = new ArrayList<ECKey>(keys.size());
|
||||
List<ECKey> actuallyAdded = new ArrayList<>(keys.size());
|
||||
for (final ECKey key : keys) {
|
||||
if (hasKey(key)) continue;
|
||||
actuallyAdded.add(key);
|
||||
@ -284,7 +284,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
public List<ListenerRegistration<KeyChainEventListener>> getListeners() {
|
||||
return new ArrayList<ListenerRegistration<KeyChainEventListener>>(listeners);
|
||||
return new ArrayList<>(listeners);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -294,7 +294,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Map<ECKey, Protos.Key.Builder> serializeToEditableProtobufs() {
|
||||
Map<ECKey, Protos.Key.Builder> result = new LinkedHashMap<ECKey, Protos.Key.Builder>();
|
||||
Map<ECKey, Protos.Key.Builder> result = new LinkedHashMap<>();
|
||||
for (ECKey ecKey : hashToKeys.values()) {
|
||||
Protos.Key.Builder protoKey = serializeEncryptableItem(ecKey);
|
||||
protoKey.setPublicKey(ByteString.copyFrom(ecKey.getPubKey()));
|
||||
@ -306,7 +306,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
@Override
|
||||
public List<Protos.Key> serializeToProtobuf() {
|
||||
Collection<Protos.Key.Builder> builders = serializeToEditableProtobufs().values();
|
||||
List<Protos.Key> result = new ArrayList<Protos.Key>(builders.size());
|
||||
List<Protos.Key> result = new ArrayList<>(builders.size());
|
||||
for (Protos.Key.Builder builder : builders) result.add(builder.build());
|
||||
return result;
|
||||
}
|
||||
@ -407,7 +407,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
|
||||
@Override
|
||||
public void addEventListener(KeyChainEventListener listener, Executor executor) {
|
||||
listeners.add(new ListenerRegistration<KeyChainEventListener>(listener, executor));
|
||||
listeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ public class DecryptingKeyBag implements KeyBag {
|
||||
}
|
||||
|
||||
private RedeemData maybeDecrypt(RedeemData redeemData) {
|
||||
List<ECKey> decryptedKeys = new ArrayList<ECKey>();
|
||||
List<ECKey> decryptedKeys = new ArrayList<>();
|
||||
for (ECKey key : redeemData.keys) {
|
||||
decryptedKeys.add(maybeDecrypt(key));
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ import java.util.*;
|
||||
public class DefaultCoinSelector implements CoinSelector {
|
||||
@Override
|
||||
public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
|
||||
ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>();
|
||||
ArrayList<TransactionOutput> selected = new ArrayList<>();
|
||||
// Sort the inputs by age*value so we get the highest "coindays" spent.
|
||||
// TODO: Consider changing the wallets internal format to track just outputs and keep them ordered.
|
||||
ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates);
|
||||
ArrayList<TransactionOutput> sortedOutputs = new ArrayList<>(candidates);
|
||||
// When calculating the wallet balance, we may be asked to select all possible coins, if so, avoid sorting
|
||||
// them in order to improve performance.
|
||||
// TODO: Take in network parameters when instanatiated, and then test against the current network. Or just have a boolean parameter for "give me everything"
|
||||
|
@ -489,7 +489,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
// and calculate the full lookahead zone there, so network requests will always use the right amount.
|
||||
List<DeterministicKey> lookahead = maybeLookAhead(parentKey, index, 0, 0);
|
||||
basicKeyChain.importKeys(lookahead);
|
||||
List<DeterministicKey> keys = new ArrayList<DeterministicKey>(numberOfKeys);
|
||||
List<DeterministicKey> keys = new ArrayList<>(numberOfKeys);
|
||||
for (int i = 0; i < numberOfKeys; i++) {
|
||||
ImmutableList<ChildNumber> path = HDUtils.append(parentKey.getPath(), new ChildNumber(index - numberOfKeys + i, false));
|
||||
DeterministicKey k = hierarchy.get(path, false, false);
|
||||
@ -1153,12 +1153,12 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
final int needed = issued + lookaheadSize + lookaheadThreshold - numChildren;
|
||||
|
||||
if (needed <= lookaheadThreshold)
|
||||
return new ArrayList<DeterministicKey>();
|
||||
return new ArrayList<>();
|
||||
|
||||
log.info("{} keys needed for {} = {} issued + {} lookahead size + {} lookahead threshold - {} num children",
|
||||
needed, parent.getPathAsString(), issued, lookaheadSize, lookaheadThreshold, numChildren);
|
||||
|
||||
List<DeterministicKey> result = new ArrayList<DeterministicKey>(needed);
|
||||
List<DeterministicKey> result = new ArrayList<>(needed);
|
||||
final Stopwatch watch = Stopwatch.createStarted();
|
||||
int nextChild = numChildren;
|
||||
for (int i = 0; i < needed; i++) {
|
||||
@ -1219,7 +1219,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
List<ECKey> keys = basicKeyChain.getKeys();
|
||||
if (!includeLookahead) {
|
||||
int treeSize = internalParentKey.getPath().size();
|
||||
List<ECKey> issuedKeys = new LinkedList<ECKey>();
|
||||
List<ECKey> issuedKeys = new LinkedList<>();
|
||||
for (ECKey key : keys) {
|
||||
DeterministicKey detkey = (DeterministicKey) key;
|
||||
DeterministicKey parent = detkey.getParent();
|
||||
@ -1238,7 +1238,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
* Returns only the external keys that have been issued by this chain, lookahead not included.
|
||||
*/
|
||||
public List<ECKey> getIssuedReceiveKeys() {
|
||||
final List<ECKey> keys = new ArrayList<ECKey>(getKeys(false, false));
|
||||
final List<ECKey> keys = new ArrayList<>(getKeys(false, false));
|
||||
for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) {
|
||||
DeterministicKey parent = ((DeterministicKey) i.next()).getParent();
|
||||
if (parent == null || !externalParentKey.equals(parent))
|
||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||
*/
|
||||
public class FilteringCoinSelector implements CoinSelector {
|
||||
protected CoinSelector delegate;
|
||||
protected HashSet<TransactionOutPoint> spent = new HashSet<TransactionOutPoint>();
|
||||
protected HashSet<TransactionOutPoint> spent = new HashSet<>();
|
||||
|
||||
public FilteringCoinSelector(CoinSelector delegate) {
|
||||
this.delegate = delegate;
|
||||
|
@ -97,12 +97,12 @@ public class KeyChainGroup implements KeyBag {
|
||||
@Nullable EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys, @Nullable KeyCrypter crypter) {
|
||||
this.params = params;
|
||||
this.basic = basicKeyChain == null ? new BasicKeyChain() : basicKeyChain;
|
||||
this.chains = new LinkedList<DeterministicKeyChain>(checkNotNull(chains));
|
||||
this.chains = new LinkedList<>(checkNotNull(chains));
|
||||
this.keyCrypter = crypter;
|
||||
this.currentKeys = currentKeys == null
|
||||
? new EnumMap<KeyChain.KeyPurpose, DeterministicKey>(KeyChain.KeyPurpose.class)
|
||||
: currentKeys;
|
||||
this.currentAddresses = new EnumMap<KeyChain.KeyPurpose, Address>(KeyChain.KeyPurpose.class);
|
||||
this.currentAddresses = new EnumMap<>(KeyChain.KeyPurpose.class);
|
||||
maybeLookaheadScripts();
|
||||
|
||||
if (isMarried()) {
|
||||
@ -491,7 +491,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
checkNotNull(aesKey);
|
||||
// This code must be exception safe.
|
||||
BasicKeyChain newBasic = basic.toEncrypted(keyCrypter, aesKey);
|
||||
List<DeterministicKeyChain> newChains = new ArrayList<DeterministicKeyChain>(chains.size());
|
||||
List<DeterministicKeyChain> newChains = new ArrayList<>(chains.size());
|
||||
if (chains.isEmpty() && basic.numKeys() == 0) {
|
||||
// No HD chains and no random keys: encrypting an entirely empty keychain group. But we can't do that, we
|
||||
// must have something to encrypt: so instantiate a new HD chain here.
|
||||
@ -515,7 +515,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
// This code must be exception safe.
|
||||
checkNotNull(aesKey);
|
||||
BasicKeyChain newBasic = basic.toDecrypted(aesKey);
|
||||
List<DeterministicKeyChain> newChains = new ArrayList<DeterministicKeyChain>(chains.size());
|
||||
List<DeterministicKeyChain> newChains = new ArrayList<>(chains.size());
|
||||
for (DeterministicKeyChain chain : chains)
|
||||
newChains.add(chain.toDecrypted(aesKey));
|
||||
|
||||
@ -746,7 +746,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
private static EnumMap<KeyChain.KeyPurpose, DeterministicKey> createCurrentKeysMap(List<DeterministicKeyChain> chains) {
|
||||
DeterministicKeyChain activeChain = chains.get(chains.size() - 1);
|
||||
|
||||
EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys = new EnumMap<KeyChain.KeyPurpose, DeterministicKey>(KeyChain.KeyPurpose.class);
|
||||
EnumMap<KeyChain.KeyPurpose, DeterministicKey> currentKeys = new EnumMap<>(KeyChain.KeyPurpose.class);
|
||||
|
||||
// assuming that only RECEIVE and CHANGE keys are being used at the moment, we will treat latest issued external key
|
||||
// as current RECEIVE key and latest issued internal key as CHANGE key. This should be changed as soon as other
|
||||
@ -801,7 +801,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
|
||||
/** Returns a copy of the current list of chains. */
|
||||
public List<DeterministicKeyChain> getDeterministicKeyChains() {
|
||||
return new ArrayList<DeterministicKeyChain>(chains);
|
||||
return new ArrayList<>(chains);
|
||||
}
|
||||
/**
|
||||
* Returns a counter that increases (by an arbitrary amount) each time new keys have been calculated due to
|
||||
|
@ -57,7 +57,7 @@ import static com.google.common.collect.Lists.newArrayList;
|
||||
public class MarriedKeyChain extends DeterministicKeyChain {
|
||||
// The map holds P2SH redeem script and corresponding ECKeys issued by this KeyChainGroup (including lookahead)
|
||||
// mapped to redeem script hashes.
|
||||
private LinkedHashMap<ByteString, RedeemData> marriedKeysRedeemData = new LinkedHashMap<ByteString, RedeemData>();
|
||||
private LinkedHashMap<ByteString, RedeemData> marriedKeysRedeemData = new LinkedHashMap<>();
|
||||
|
||||
private List<DeterministicKeyChain> followingKeyChains;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class RedeemData {
|
||||
|
||||
private RedeemData(List<ECKey> keys, Script redeemScript) {
|
||||
this.redeemScript = redeemScript;
|
||||
List<ECKey> sortedKeys = new ArrayList<ECKey>(keys);
|
||||
List<ECKey> sortedKeys = new ArrayList<>(keys);
|
||||
Collections.sort(sortedKeys, ECKey.PUBKEY_COMPARATOR);
|
||||
this.keys = sortedKeys;
|
||||
}
|
||||
|
@ -192,17 +192,17 @@ public class Wallet extends BaseTaggableObject
|
||||
private long lastBlockSeenTimeSecs;
|
||||
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<WalletChangeEventListener>> changeListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<WalletChangeEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<WalletCoinsReceivedEventListener>> coinsReceivedListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<WalletCoinsReceivedEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<WalletCoinsSentEventListener>> coinsSentListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<WalletCoinsSentEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<WalletReorganizeEventListener>> reorganizeListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<WalletReorganizeEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<ScriptsChangeEventListener>> scriptChangeListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<ScriptsChangeEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
private final CopyOnWriteArrayList<ListenerRegistration<TransactionConfidenceEventListener>> transactionConfidenceListeners
|
||||
= new CopyOnWriteArrayList<ListenerRegistration<TransactionConfidenceEventListener>>();
|
||||
= new CopyOnWriteArrayList<>();
|
||||
|
||||
// A listener that relays confidence changes from the transaction confidence object to the wallet event listener,
|
||||
// as a convenience to API users so they don't have to register on every transaction themselves.
|
||||
@ -319,21 +319,21 @@ public class Wallet extends BaseTaggableObject
|
||||
if (this.keyChainGroup.numKeys() == 0)
|
||||
this.keyChainGroup.createAndActivateNewHDChain();
|
||||
watchedScripts = Sets.newHashSet();
|
||||
unspent = new HashMap<Sha256Hash, Transaction>();
|
||||
spent = new HashMap<Sha256Hash, Transaction>();
|
||||
pending = new HashMap<Sha256Hash, Transaction>();
|
||||
dead = new HashMap<Sha256Hash, Transaction>();
|
||||
transactions = new HashMap<Sha256Hash, Transaction>();
|
||||
extensions = new HashMap<String, WalletExtension>();
|
||||
unspent = new HashMap<>();
|
||||
spent = new HashMap<>();
|
||||
pending = new HashMap<>();
|
||||
dead = new HashMap<>();
|
||||
transactions = new HashMap<>();
|
||||
extensions = new HashMap<>();
|
||||
// Use a linked hash map to ensure ordering of event listeners is correct.
|
||||
confidenceChanged = new LinkedHashMap<Transaction, TransactionConfidence.Listener.ChangeReason>();
|
||||
signers = new ArrayList<TransactionSigner>();
|
||||
confidenceChanged = new LinkedHashMap<>();
|
||||
signers = new ArrayList<>();
|
||||
addTransactionSigner(new LocalTransactionSigner());
|
||||
createTransientState();
|
||||
}
|
||||
|
||||
private void createTransientState() {
|
||||
ignoreNextNewBlock = new HashSet<Sha256Hash>();
|
||||
ignoreNextNewBlock = new HashSet<>();
|
||||
txConfidenceListener = new TransactionConfidence.Listener() {
|
||||
@Override
|
||||
public void onConfidenceChanged(TransactionConfidence confidence, TransactionConfidence.Listener.ChangeReason reason) {
|
||||
@ -532,7 +532,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public List<Address> getIssuedReceiveAddresses() {
|
||||
final List<ECKey> keys = getIssuedReceiveKeys();
|
||||
List<Address> addresses = new ArrayList<Address>(keys.size());
|
||||
List<Address> addresses = new ArrayList<>(keys.size());
|
||||
for (ECKey key : keys)
|
||||
addresses.add(key.toAddress(getParams()));
|
||||
return addresses;
|
||||
@ -593,7 +593,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public List<Script> getWatchedScripts() {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
return new ArrayList<Script>(watchedScripts);
|
||||
return new ArrayList<>(watchedScripts);
|
||||
} finally {
|
||||
keyChainGroupLock.unlock();
|
||||
}
|
||||
@ -961,7 +961,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public List<Address> getWatchedAddresses() {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
List<Address> addresses = new LinkedList<Address>();
|
||||
List<Address> addresses = new LinkedList<>();
|
||||
for (Script script : watchedScripts)
|
||||
if (script.isSentToAddress())
|
||||
addresses.add(script.getToAddress(params));
|
||||
@ -1546,7 +1546,7 @@ public class Wallet extends BaseTaggableObject
|
||||
try {
|
||||
Set<Transaction> transactions = getTransactions(true);
|
||||
|
||||
Set<Sha256Hash> hashes = new HashSet<Sha256Hash>();
|
||||
Set<Sha256Hash> hashes = new HashSet<>();
|
||||
for (Transaction tx : transactions) {
|
||||
hashes.add(tx.getHash());
|
||||
}
|
||||
@ -1813,7 +1813,7 @@ public class Wallet extends BaseTaggableObject
|
||||
checkState(lock.isHeldByCurrentThread());
|
||||
if (tx.isCoinBase()) return Sets.newHashSet();
|
||||
// Compile a set of outpoints that are spent by tx.
|
||||
HashSet<TransactionOutPoint> outpoints = new HashSet<TransactionOutPoint>();
|
||||
HashSet<TransactionOutPoint> outpoints = new HashSet<>();
|
||||
for (TransactionInput input : tx.getInputs()) {
|
||||
outpoints.add(input.getOutpoint());
|
||||
}
|
||||
@ -1838,7 +1838,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* and all txns spending the outputs of those txns, recursively.
|
||||
*/
|
||||
void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) {
|
||||
Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, Transaction>();
|
||||
Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<>();
|
||||
for (Transaction tx : txSet) {
|
||||
txQueue.put(tx.getHash(), tx);
|
||||
}
|
||||
@ -2053,7 +2053,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* as there is no guarantee on the order of the returned txns besides what was already stated.
|
||||
*/
|
||||
List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) {
|
||||
ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet);
|
||||
ArrayList<Transaction> result = new ArrayList<>(inputSet);
|
||||
for (int i = 0; i < result.size()-1; i++) {
|
||||
boolean txAtISpendsOtherTxInTheList;
|
||||
do {
|
||||
@ -2315,7 +2315,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
// Updates the wallet when a double spend occurs. overridingTx can be null for the case of coinbases
|
||||
private void killTxns(Set<Transaction> txnsToKill, @Nullable Transaction overridingTx) {
|
||||
LinkedList<Transaction> work = new LinkedList<Transaction>(txnsToKill);
|
||||
LinkedList<Transaction> work = new LinkedList<>(txnsToKill);
|
||||
while (!work.isEmpty()) {
|
||||
final Transaction tx = work.poll();
|
||||
log.warn("TX {} killed{}", tx.getHashAsString(),
|
||||
@ -2544,7 +2544,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addChangeEventListener(Executor executor, WalletChangeEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
changeListeners.add(new ListenerRegistration<WalletChangeEventListener>(listener, executor));
|
||||
changeListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2561,7 +2561,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addCoinsReceivedEventListener(Executor executor, WalletCoinsReceivedEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
coinsReceivedListeners.add(new ListenerRegistration<WalletCoinsReceivedEventListener>(listener, executor));
|
||||
coinsReceivedListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2578,7 +2578,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addCoinsSentEventListener(Executor executor, WalletCoinsSentEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
coinsSentListeners.add(new ListenerRegistration<WalletCoinsSentEventListener>(listener, executor));
|
||||
coinsSentListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2611,7 +2611,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addReorganizeEventListener(Executor executor, WalletReorganizeEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
reorganizeListeners.add(new ListenerRegistration<WalletReorganizeEventListener>(listener, executor));
|
||||
reorganizeListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2628,7 +2628,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addScriptChangeEventListener(Executor executor, ScriptsChangeEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
scriptChangeListeners.add(new ListenerRegistration<ScriptsChangeEventListener>(listener, executor));
|
||||
scriptChangeListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2645,7 +2645,7 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
public void addTransactionConfidenceEventListener(Executor executor, TransactionConfidenceEventListener listener) {
|
||||
// This is thread safe, so we don't need to take the lock.
|
||||
transactionConfidenceListeners.add(new ListenerRegistration<TransactionConfidenceEventListener>(listener, executor));
|
||||
transactionConfidenceListeners.add(new ListenerRegistration<>(listener, executor));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2812,7 +2812,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public Set<Transaction> getTransactions(boolean includeDead) {
|
||||
lock.lock();
|
||||
try {
|
||||
Set<Transaction> all = new HashSet<Transaction>();
|
||||
Set<Transaction> all = new HashSet<>();
|
||||
all.addAll(unspent.values());
|
||||
all.addAll(spent.values());
|
||||
all.addAll(pending.values());
|
||||
@ -2830,7 +2830,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public Iterable<WalletTransaction> getWalletTransactions() {
|
||||
lock.lock();
|
||||
try {
|
||||
Set<WalletTransaction> all = new HashSet<WalletTransaction>();
|
||||
Set<WalletTransaction> all = new HashSet<>();
|
||||
addWalletTransactionsToSet(all, Pool.UNSPENT, unspent.values());
|
||||
addWalletTransactionsToSet(all, Pool.SPENT, spent.values());
|
||||
addWalletTransactionsToSet(all, Pool.DEAD, dead.values());
|
||||
@ -2919,7 +2919,7 @@ public class Wallet extends BaseTaggableObject
|
||||
if (numTransactions > size || numTransactions == 0) {
|
||||
numTransactions = size;
|
||||
}
|
||||
ArrayList<Transaction> all = new ArrayList<Transaction>(getTransactions(includeDead));
|
||||
ArrayList<Transaction> all = new ArrayList<>(getTransactions(includeDead));
|
||||
// Order by update time.
|
||||
Collections.sort(all, Transaction.SORT_TX_BY_UPDATE_TIME);
|
||||
if (numTransactions == all.size()) {
|
||||
@ -3158,7 +3158,7 @@ public class Wallet extends BaseTaggableObject
|
||||
public List<TransactionOutput> getUnspents() {
|
||||
lock.lock();
|
||||
try {
|
||||
return new ArrayList<TransactionOutput>(myUnspents);
|
||||
return new ArrayList<>(myUnspents);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@ -3256,7 +3256,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
final Collection<Transaction> txns;
|
||||
if (sortOrder != null) {
|
||||
txns = new TreeSet<Transaction>(sortOrder);
|
||||
txns = new TreeSet<>(sortOrder);
|
||||
txns.addAll(transactionMap.values());
|
||||
} else {
|
||||
txns = transactionMap.values();
|
||||
@ -3941,7 +3941,7 @@ public class Wallet extends BaseTaggableObject
|
||||
log.warn("SendRequest transaction already has inputs but we don't know how much they are worth - they will be added to fee.");
|
||||
value = value.subtract(totalInput);
|
||||
|
||||
List<TransactionInput> originalInputs = new ArrayList<TransactionInput>(req.tx.getInputs());
|
||||
List<TransactionInput> originalInputs = new ArrayList<>(req.tx.getInputs());
|
||||
|
||||
// Check for dusty sends and the OP_RETURN limit.
|
||||
if (req.ensureMinRequiredFee && !req.emptyWallet) { // Min fee checking is handled later for emptyWallet.
|
||||
@ -4120,7 +4120,7 @@ public class Wallet extends BaseTaggableObject
|
||||
try {
|
||||
List<TransactionOutput> candidates;
|
||||
if (vUTXOProvider == null) {
|
||||
candidates = new ArrayList<TransactionOutput>(myUnspents.size());
|
||||
candidates = new ArrayList<>(myUnspents.size());
|
||||
for (TransactionOutput output : myUnspents) {
|
||||
if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
|
||||
Transaction transaction = checkNotNull(output.getParentTransaction());
|
||||
@ -4223,10 +4223,10 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
protected List<UTXO> getStoredOutputsFromUTXOProvider() throws UTXOProviderException {
|
||||
UTXOProvider utxoProvider = checkNotNull(vUTXOProvider, "No UTXO provider has been set");
|
||||
List<UTXO> candidates = new ArrayList<UTXO>();
|
||||
List<UTXO> candidates = new ArrayList<>();
|
||||
List<ECKey> keys = getImportedKeys();
|
||||
keys.addAll(getActiveKeyChain().getLeafKeys());
|
||||
List<Address> addresses = new ArrayList<Address>();
|
||||
List<Address> addresses = new ArrayList<>();
|
||||
for (ECKey key : keys) {
|
||||
Address address = new Address(params, key.getPubKeyHash());
|
||||
addresses.add(address);
|
||||
@ -4421,7 +4421,7 @@ public class Wallet extends BaseTaggableObject
|
||||
for (Sha256Hash blockHash : mapBlockTx.keySet())
|
||||
Collections.sort(mapBlockTx.get(blockHash));
|
||||
|
||||
List<Sha256Hash> oldBlockHashes = new ArrayList<Sha256Hash>(oldBlocks.size());
|
||||
List<Sha256Hash> oldBlockHashes = new ArrayList<>(oldBlocks.size());
|
||||
log.info("Old part of chain (top to bottom):");
|
||||
for (StoredBlock b : oldBlocks) {
|
||||
log.info(" {}", b.getHeader().getHashAsString());
|
||||
@ -4567,7 +4567,7 @@ public class Wallet extends BaseTaggableObject
|
||||
private void calcBloomOutPointsLocked() {
|
||||
// TODO: This could be done once and then kept up to date.
|
||||
bloomOutPoints.clear();
|
||||
Set<Transaction> all = new HashSet<Transaction>();
|
||||
Set<Transaction> all = new HashSet<>();
|
||||
all.addAll(unspent.values());
|
||||
all.addAll(spent.values());
|
||||
all.addAll(pending.values());
|
||||
@ -4848,7 +4848,7 @@ public class Wallet extends BaseTaggableObject
|
||||
// Of the coins we could spend, pick some that we actually will spend.
|
||||
CoinSelector selector = req.coinSelector == null ? coinSelector : req.coinSelector;
|
||||
// selector is allowed to modify candidates list.
|
||||
CoinSelection selection = selector.select(valueNeeded, new LinkedList<TransactionOutput>(candidates));
|
||||
CoinSelection selection = selector.select(valueNeeded, new LinkedList<>(candidates));
|
||||
// Can we afford this?
|
||||
if (selection.valueGathered.compareTo(valueNeeded) < 0) {
|
||||
valueMissing = valueNeeded.subtract(selection.valueGathered);
|
||||
@ -5155,7 +5155,7 @@ public class Wallet extends BaseTaggableObject
|
||||
lock.unlock();
|
||||
}
|
||||
checkState(!lock.isHeldByCurrentThread());
|
||||
ArrayList<ListenableFuture<Transaction>> futures = new ArrayList<ListenableFuture<Transaction>>(txns.size());
|
||||
ArrayList<ListenableFuture<Transaction>> futures = new ArrayList<>(txns.size());
|
||||
TransactionBroadcaster broadcaster = vTransactionBroadcaster;
|
||||
for (Transaction tx : txns) {
|
||||
try {
|
||||
|
@ -99,7 +99,7 @@ public class WalletProtobufSerializer {
|
||||
}
|
||||
|
||||
public WalletProtobufSerializer(WalletFactory factory) {
|
||||
txMap = new HashMap<ByteString, Transaction>();
|
||||
txMap = new HashMap<>();
|
||||
this.factory = factory;
|
||||
this.keyChainFactory = new DefaultKeyChainFactory();
|
||||
}
|
||||
@ -577,7 +577,7 @@ public class WalletProtobufSerializer {
|
||||
}
|
||||
|
||||
private void loadExtensions(Wallet wallet, WalletExtension[] extensionsList, Protos.Wallet walletProto) throws UnreadableWalletException {
|
||||
final Map<String, WalletExtension> extensions = new HashMap<String, WalletExtension>();
|
||||
final Map<String, WalletExtension> extensions = new HashMap<>();
|
||||
for (WalletExtension e : extensionsList)
|
||||
extensions.put(e.getWalletExtensionID(), e);
|
||||
// The Wallet object, if subclassed, might have added some extensions to itself already. In that case, don't
|
||||
|
@ -193,12 +193,12 @@ public abstract class AbstractFullPrunedBlockChainTest {
|
||||
rollingBlock.solve();
|
||||
|
||||
chain.add(rollingBlock);
|
||||
WeakReference<StoredUndoableBlock> undoBlock = new WeakReference<StoredUndoableBlock>(store.getUndoBlock(rollingBlock.getHash()));
|
||||
WeakReference<StoredUndoableBlock> undoBlock = new WeakReference<>(store.getUndoBlock(rollingBlock.getHash()));
|
||||
|
||||
StoredUndoableBlock storedUndoableBlock = undoBlock.get();
|
||||
assertNotNull(storedUndoableBlock);
|
||||
assertNull(storedUndoableBlock.getTransactions());
|
||||
WeakReference<TransactionOutputChanges> changes = new WeakReference<TransactionOutputChanges>(storedUndoableBlock.getTxOutChanges());
|
||||
WeakReference<TransactionOutputChanges> changes = new WeakReference<>(storedUndoableBlock.getTxOutChanges());
|
||||
assertNotNull(changes.get());
|
||||
storedUndoableBlock = null; // Blank the reference so it can be GCd.
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class BitcoindComparisonTool {
|
||||
|
||||
FullBlockTestGenerator generator = new FullBlockTestGenerator(params);
|
||||
final RuleList blockList = generator.getBlocksToTest(false, runExpensiveTests, blockFile);
|
||||
final Map<Sha256Hash, Block> preloadedBlocks = new HashMap<Sha256Hash, Block>();
|
||||
final Map<Sha256Hash, Block> preloadedBlocks = new HashMap<>();
|
||||
final Iterator<Block> blocks = new BlockFileLoader(params, Arrays.asList(blockFile));
|
||||
|
||||
try {
|
||||
@ -155,13 +155,13 @@ public class BitcoindComparisonTool {
|
||||
log.info("Got a request for a header before we had even begun processing blocks!");
|
||||
return null;
|
||||
}
|
||||
LinkedList<Block> headers = new LinkedList<Block>();
|
||||
LinkedList<Block> headers = new LinkedList<>();
|
||||
Block it = blockList.hashHeaderMap.get(currentBlock.block.getHash());
|
||||
while (it != null) {
|
||||
headers.addFirst(it);
|
||||
it = blockList.hashHeaderMap.get(it.getPrevBlockHash());
|
||||
}
|
||||
LinkedList<Block> sendHeaders = new LinkedList<Block>();
|
||||
LinkedList<Block> sendHeaders = new LinkedList<>();
|
||||
boolean found = false;
|
||||
for (Sha256Hash hash : ((GetHeadersMessage) m).getLocator()) {
|
||||
for (Block b : headers) {
|
||||
@ -207,7 +207,7 @@ public class BitcoindComparisonTool {
|
||||
|
||||
connectedFuture.get();
|
||||
|
||||
ArrayList<Sha256Hash> locator = new ArrayList<Sha256Hash>(1);
|
||||
ArrayList<Sha256Hash> locator = new ArrayList<>(1);
|
||||
locator.add(params.getGenesisBlock().getHash());
|
||||
Sha256Hash hashTo = Sha256Hash.wrap("0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
@ -318,7 +318,7 @@ public class BitcoindComparisonTool {
|
||||
log.error("ERROR: bitcoind had a non-empty mempool, but we expected an empty one on rule " + rule.ruleName);
|
||||
rulesSinceFirstFail++;
|
||||
} else if (mostRecentInv != null) {
|
||||
Set<InventoryItem> originalRuleSet = new HashSet<InventoryItem>(((MemoryPoolState)rule).mempool);
|
||||
Set<InventoryItem> originalRuleSet = new HashSet<>(((MemoryPoolState)rule).mempool);
|
||||
boolean matches = mostRecentInv.items.size() == ((MemoryPoolState)rule).mempool.size();
|
||||
for (InventoryItem item : mostRecentInv.items)
|
||||
if (!((MemoryPoolState) rule).mempool.remove(item))
|
||||
|
@ -400,7 +400,7 @@ public class ChainSplitTest {
|
||||
public void txConfidenceLevels() throws Exception {
|
||||
// Check that as the chain forks and re-orgs, the confidence data associated with each transaction is
|
||||
// maintained correctly.
|
||||
final ArrayList<Transaction> txns = new ArrayList<Transaction>(3);
|
||||
final ArrayList<Transaction> txns = new ArrayList<>(3);
|
||||
wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
@ -558,7 +558,7 @@ public class ChainSplitTest {
|
||||
// Check that a coinbase tx is marked as dead after a reorg rather than pending as normal non-double-spent
|
||||
// transactions would be. Also check that a dead coinbase on a sidechain is resurrected if the sidechain
|
||||
// becomes the best chain once more. Finally, check that dependent transactions are killed recursively.
|
||||
final ArrayList<Transaction> txns = new ArrayList<Transaction>(3);
|
||||
final ArrayList<Transaction> txns = new ArrayList<>(3);
|
||||
wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, new WalletCoinsReceivedEventListener() {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
|
@ -147,10 +147,10 @@ public class FullBlockTestGenerator {
|
||||
private byte[] coinbaseOutKeyPubKey;
|
||||
|
||||
// Used to double-check that we are always using the right next-height
|
||||
private Map<Sha256Hash, Integer> blockToHeightMap = new HashMap<Sha256Hash, Integer>();
|
||||
private Map<Sha256Hash, Integer> blockToHeightMap = new HashMap<>();
|
||||
|
||||
private Map<Sha256Hash, Block> hashHeaderMap = new HashMap<Sha256Hash, Block>();
|
||||
private Map<Sha256Hash, Sha256Hash> coinbaseBlockMap = new HashMap<Sha256Hash, Sha256Hash>();
|
||||
private Map<Sha256Hash, Block> hashHeaderMap = new HashMap<>();
|
||||
private Map<Sha256Hash, Sha256Hash> coinbaseBlockMap = new HashMap<>();
|
||||
|
||||
public FullBlockTestGenerator(NetworkParameters params) {
|
||||
this.params = params;
|
||||
@ -190,7 +190,7 @@ public class FullBlockTestGenerator {
|
||||
};
|
||||
RuleList ret = new RuleList(blocks, hashHeaderMap, 10);
|
||||
|
||||
Queue<TransactionOutPointWithValue> spendableOutputs = new LinkedList<TransactionOutPointWithValue>();
|
||||
Queue<TransactionOutPointWithValue> spendableOutputs = new LinkedList<>();
|
||||
|
||||
int chainHeadHeight = 1;
|
||||
Block chainHead = params.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, coinbaseOutKeyPubKey, chainHeadHeight);
|
||||
@ -958,7 +958,7 @@ public class FullBlockTestGenerator {
|
||||
// A block with no txn
|
||||
Block b46 = new Block(params, Block.BLOCK_VERSION_GENESIS);
|
||||
{
|
||||
b46.transactions = new ArrayList<Transaction>();
|
||||
b46.transactions = new ArrayList<>();
|
||||
b46.setDifficultyTarget(b44.getDifficultyTarget());
|
||||
b46.setMerkleRoot(Sha256Hash.ZERO_HASH);
|
||||
|
||||
@ -1510,7 +1510,7 @@ public class FullBlockTestGenerator {
|
||||
blocks.add(new BlockAndValidity(b82, true, false, b82.getHash(), chainHeadHeight + 28, "b82"));
|
||||
spendableOutputs.offer(b82.getCoinbaseOutput());
|
||||
|
||||
HashSet<InventoryItem> post82Mempool = new HashSet<InventoryItem>();
|
||||
HashSet<InventoryItem> post82Mempool = new HashSet<>();
|
||||
post82Mempool.add(new InventoryItem(InventoryItem.Type.Transaction, b78tx.getHash()));
|
||||
post82Mempool.add(new InventoryItem(InventoryItem.Type.Transaction, b79tx.getHash()));
|
||||
blocks.add(new MemoryPoolState(post82Mempool, "post-b82 tx resurrection"));
|
||||
@ -1693,7 +1693,7 @@ public class FullBlockTestGenerator {
|
||||
int blockCountAfter1001;
|
||||
int nextHeight = heightAfter1001;
|
||||
|
||||
List<Sha256Hash> hashesToSpend = new LinkedList<Sha256Hash>(); // all index 0
|
||||
List<Sha256Hash> hashesToSpend = new LinkedList<>(); // all index 0
|
||||
final int TRANSACTION_CREATION_BLOCKS = 100;
|
||||
for (blockCountAfter1001 = 0; blockCountAfter1001 < TRANSACTION_CREATION_BLOCKS; blockCountAfter1001++) {
|
||||
NewBlock block = createNextBlock(lastBlock, nextHeight++, null, null);
|
||||
|
@ -77,9 +77,9 @@ public class PeerGroupTest extends TestWithPeerGroup {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
peerToMessageCount = new HashMap<Peer, AtomicInteger>();
|
||||
connectedPeers = new LinkedBlockingQueue<Peer>();
|
||||
disconnectedPeers = new LinkedBlockingQueue<Peer>();
|
||||
peerToMessageCount = new HashMap<>();
|
||||
connectedPeers = new LinkedBlockingQueue<>();
|
||||
disconnectedPeers = new LinkedBlockingQueue<>();
|
||||
preMessageReceivedListener = new PreMessageReceivedEventListener() {
|
||||
@Override
|
||||
public Message onPreMessageReceived(Peer peer, Message m) {
|
||||
@ -207,8 +207,8 @@ public class PeerGroupTest extends TestWithPeerGroup {
|
||||
|
||||
// Check the peer accessors.
|
||||
assertEquals(2, peerGroup.numConnectedPeers());
|
||||
Set<Peer> tmp = new HashSet<Peer>(peerGroup.getConnectedPeers());
|
||||
Set<Peer> expectedPeers = new HashSet<Peer>();
|
||||
Set<Peer> tmp = new HashSet<>(peerGroup.getConnectedPeers());
|
||||
Set<Peer> expectedPeers = new HashSet<>();
|
||||
expectedPeers.add(peerOf(p1));
|
||||
expectedPeers.add(peerOf(p2));
|
||||
assertEquals(tmp, expectedPeers);
|
||||
@ -783,7 +783,7 @@ public class PeerGroupTest extends TestWithPeerGroup {
|
||||
|
||||
// First, grab a load of keys from the wallet, and then recreate it so it forgets that those keys were issued.
|
||||
Wallet shadow = Wallet.fromSeed(wallet.getParams(), wallet.getKeyChainSeed());
|
||||
List<ECKey> keys = new ArrayList<ECKey>(NUM_KEYS);
|
||||
List<ECKey> keys = new ArrayList<>(NUM_KEYS);
|
||||
for (int i = 0; i < NUM_KEYS; i++) {
|
||||
keys.add(shadow.freshReceiveKey());
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
||||
inbound(writeTarget, inv);
|
||||
|
||||
GetBlocksMessage getblocks = (GetBlocksMessage)outbound(writeTarget);
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<>();
|
||||
expectedLocator.add(b1.getHash());
|
||||
expectedLocator.add(PARAMS.getGenesisBlock().getHash());
|
||||
|
||||
@ -395,7 +395,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
||||
});
|
||||
peer.startBlockChainDownload();
|
||||
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<>();
|
||||
expectedLocator.add(b2.getHash());
|
||||
expectedLocator.add(b1.getHash());
|
||||
expectedLocator.add(PARAMS.getGenesisBlock().getHash());
|
||||
@ -477,7 +477,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
||||
peer.setDownloadParameters(Utils.currentTimeSeconds() - (600*2) + 1, false);
|
||||
peer.startBlockChainDownload();
|
||||
GetHeadersMessage getheaders = (GetHeadersMessage) outbound(writeTarget);
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||
List<Sha256Hash> expectedLocator = new ArrayList<>();
|
||||
expectedLocator.add(b1.getHash());
|
||||
expectedLocator.add(PARAMS.getGenesisBlock().getHash());
|
||||
assertEquals(getheaders.getLocator(), expectedLocator);
|
||||
|
@ -299,7 +299,7 @@ public class TransactionTest {
|
||||
Transaction tx3 = FakeTxBuilder.createFakeTx(PARAMS);
|
||||
tx3.getConfidence().setAppearedAtChainHeight(3);
|
||||
|
||||
SortedSet<Transaction> set = new TreeSet<Transaction>(Transaction.SORT_TX_BY_HEIGHT);
|
||||
SortedSet<Transaction> set = new TreeSet<>(Transaction.SORT_TX_BY_HEIGHT);
|
||||
set.add(tx2);
|
||||
set.add(tx1);
|
||||
set.add(tx3);
|
||||
|
@ -213,6 +213,6 @@ public class MnemonicCodeTest {
|
||||
}
|
||||
|
||||
public static List<String> split(String words) {
|
||||
return new ArrayList<String>(Arrays.asList(words.split("\\s+")));
|
||||
return new ArrayList<>(Arrays.asList(words.split("\\s+")));
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class NetworkAbstractionTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ProtobufConnection<TwoWayChannelMessage>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
return new ProtobufConnection<>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
handler.write(msg);
|
||||
@ -127,7 +127,7 @@ public class NetworkAbstractionTests {
|
||||
server.startAsync();
|
||||
server.awaitRunning();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public synchronized void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -149,7 +149,7 @@ public class NetworkAbstractionTests {
|
||||
client1ConnectionOpened.get();
|
||||
client1Disconnected.get();
|
||||
|
||||
clientHandler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
clientHandler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public synchronized void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -198,7 +198,7 @@ public class NetworkAbstractionTests {
|
||||
NioServer server = new NioServer(new StreamConnectionFactory() {
|
||||
@Override
|
||||
public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
|
||||
return new ProtobufConnection<TwoWayChannelMessage>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
return new ProtobufConnection<>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
handler.write(msg);
|
||||
@ -220,7 +220,7 @@ public class NetworkAbstractionTests {
|
||||
server.startAsync();
|
||||
server.awaitRunning();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public synchronized void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -276,7 +276,7 @@ public class NetworkAbstractionTests {
|
||||
NioServer server = new NioServer(new StreamConnectionFactory() {
|
||||
@Override
|
||||
public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
|
||||
return new ProtobufConnection<TwoWayChannelMessage>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
return new ProtobufConnection<>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
fail.set(true);
|
||||
@ -304,7 +304,7 @@ public class NetworkAbstractionTests {
|
||||
server.startAsync();
|
||||
server.awaitRunning();
|
||||
|
||||
openConnection(new InetSocketAddress("localhost", 4243), new ProtobufConnection<TwoWayChannelMessage>(
|
||||
openConnection(new InetSocketAddress("localhost", 4243), new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -329,7 +329,7 @@ public class NetworkAbstractionTests {
|
||||
serverConnection1Closed.get();
|
||||
long closeDelayFinish = System.currentTimeMillis();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> client2Handler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> client2Handler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -375,7 +375,7 @@ public class NetworkAbstractionTests {
|
||||
NioServer server = new NioServer(new StreamConnectionFactory() {
|
||||
@Override
|
||||
public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
|
||||
return new ProtobufConnection<TwoWayChannelMessage>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
return new ProtobufConnection<>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
handler.write(msg);
|
||||
@ -396,7 +396,7 @@ public class NetworkAbstractionTests {
|
||||
server.startAsync();
|
||||
server.awaitRunning();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> clientHandler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public synchronized void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -526,7 +526,7 @@ public class NetworkAbstractionTests {
|
||||
NioServer server = new NioServer(new StreamConnectionFactory() {
|
||||
@Override
|
||||
public ProtobufConnection<TwoWayChannelMessage> getNewConnection(InetAddress inetAddress, int port) {
|
||||
return new ProtobufConnection<TwoWayChannelMessage>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
return new ProtobufConnection<>(new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
handler.write(msg);
|
||||
@ -560,7 +560,7 @@ public class NetworkAbstractionTests {
|
||||
server.startAsync();
|
||||
server.awaitRunning();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> client1Handler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> client1Handler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -582,7 +582,7 @@ public class NetworkAbstractionTests {
|
||||
client1ConnectionOpen.get();
|
||||
serverConnection1Open.get();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> client2Handler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> client2Handler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
@ -604,7 +604,7 @@ public class NetworkAbstractionTests {
|
||||
client2ConnectionOpen.get();
|
||||
serverConnection2Open.get();
|
||||
|
||||
ProtobufConnection<TwoWayChannelMessage> client3Handler = new ProtobufConnection<TwoWayChannelMessage>(
|
||||
ProtobufConnection<TwoWayChannelMessage> client3Handler = new ProtobufConnection<>(
|
||||
new ProtobufConnection.Listener<Protos.TwoWayChannelMessage>() {
|
||||
@Override
|
||||
public void messageReceived(ProtobufConnection<TwoWayChannelMessage> handler, Protos.TwoWayChannelMessage msg) {
|
||||
|
@ -124,7 +124,7 @@ public class ChannelConnectionTest extends TestWithWallet {
|
||||
|
||||
// Set up a way to monitor broadcast transactions. When you expect a broadcast, you must release a permit
|
||||
// to the broadcastTxPause semaphore so state can be queried in between.
|
||||
broadcasts = new LinkedBlockingQueue<Transaction>();
|
||||
broadcasts = new LinkedBlockingQueue<>();
|
||||
broadcastTxPause = new Semaphore(0);
|
||||
mockBroadcaster = new TransactionBroadcaster() {
|
||||
@Override
|
||||
@ -177,7 +177,7 @@ public class ChannelConnectionTest extends TestWithWallet {
|
||||
// Test with network code and without any issues. We'll broadcast two txns: multisig contract and settle transaction.
|
||||
final SettableFuture<ListenableFuture<PaymentChannelV1ServerState>> serverCloseFuture = SettableFuture.create();
|
||||
final SettableFuture<Sha256Hash> channelOpenFuture = SettableFuture.create();
|
||||
final BlockingQueue<ChannelTestUtils.UpdatePair> q = new LinkedBlockingQueue<ChannelTestUtils.UpdatePair>();
|
||||
final BlockingQueue<ChannelTestUtils.UpdatePair> q = new LinkedBlockingQueue<>();
|
||||
final PaymentChannelServerListener server = new PaymentChannelServerListener(mockBroadcaster, serverWallet, 30, COIN,
|
||||
new PaymentChannelServerListener.HandlerFactory() {
|
||||
@Nullable
|
||||
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class ChannelTestUtils {
|
||||
public static class RecordingServerConnection implements PaymentChannelServer.ServerConnection {
|
||||
public BlockingQueue<Object> q = new LinkedBlockingQueue<Object>();
|
||||
public BlockingQueue<Object> q = new LinkedBlockingQueue<>();
|
||||
|
||||
@Override
|
||||
public void sendToClient(Protos.TwoWayChannelMessage msg) {
|
||||
@ -85,7 +85,7 @@ public class ChannelTestUtils {
|
||||
}
|
||||
|
||||
public static class RecordingClientConnection implements PaymentChannelClient.ClientConnection {
|
||||
public BlockingQueue<Object> q = new LinkedBlockingQueue<Object>();
|
||||
public BlockingQueue<Object> q = new LinkedBlockingQueue<>();
|
||||
static final int IGNORE_EXPIRE = -1;
|
||||
private final int maxExpireTime;
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class PaymentChannelClientTest {
|
||||
maxValue = Coin.COIN;
|
||||
serverHash = Sha256Hash.of("serverId".getBytes());
|
||||
connection = createMock(IPaymentChannelClient.ClientConnection.class);
|
||||
clientVersionCapture = new Capture<TwoWayChannelMessage>();
|
||||
clientVersionCapture = new Capture<>();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -69,7 +69,7 @@ public class PaymentChannelServerTest {
|
||||
@Test
|
||||
public void shouldAcceptDefaultTimeWindow() {
|
||||
final TwoWayChannelMessage message = createClientVersionMessage();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<TwoWayChannelMessage>();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<>();
|
||||
connection.sendToClient(capture(initiateCapture));
|
||||
replay(connection);
|
||||
|
||||
@ -88,7 +88,7 @@ public class PaymentChannelServerTest {
|
||||
final int minTimeWindow = 20000;
|
||||
final int timeWindow = minTimeWindow - 1;
|
||||
final TwoWayChannelMessage message = createClientVersionMessage(timeWindow);
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<TwoWayChannelMessage>();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<>();
|
||||
connection.sendToClient(capture(initiateCapture));
|
||||
|
||||
replay(connection);
|
||||
@ -116,7 +116,7 @@ public class PaymentChannelServerTest {
|
||||
final int maxTimeWindow = 40000;
|
||||
final int timeWindow = maxTimeWindow + 1;
|
||||
final TwoWayChannelMessage message = createClientVersionMessage(timeWindow);
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<TwoWayChannelMessage>();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<>();
|
||||
connection.sendToClient(capture(initiateCapture));
|
||||
replay(connection);
|
||||
|
||||
@ -162,7 +162,7 @@ public class PaymentChannelServerTest {
|
||||
@Test
|
||||
public void shouldAllowExactTimeWindow() {
|
||||
final TwoWayChannelMessage message = createClientVersionMessage();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<TwoWayChannelMessage>();
|
||||
final Capture<TwoWayChannelMessage> initiateCapture = new Capture<>();
|
||||
connection.sendToClient(capture(initiateCapture));
|
||||
replay(connection);
|
||||
final int expire = 24 * 60 * 60 - 60; // This the default defined in paymentchannel.proto
|
||||
|
@ -105,7 +105,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
||||
serverKey = serverWallet.freshReceiveKey();
|
||||
chain.addWallet(serverWallet);
|
||||
|
||||
broadcasts = new LinkedBlockingQueue<TxFuturePair>();
|
||||
broadcasts = new LinkedBlockingQueue<>();
|
||||
mockBroadcaster = new TransactionBroadcaster() {
|
||||
@Override
|
||||
public TransactionBroadcast broadcastTransaction(Transaction tx) {
|
||||
|
@ -121,7 +121,7 @@ public class PaymentProtocolTest {
|
||||
@Test
|
||||
public void testPaymentMessage() throws Exception {
|
||||
// Create
|
||||
List<Transaction> transactions = new LinkedList<Transaction>();
|
||||
List<Transaction> transactions = new LinkedList<>();
|
||||
transactions.add(FakeTxBuilder.createFakeTx(NETWORK_PARAMS, AMOUNT, TO_ADDRESS));
|
||||
Coin refundAmount = Coin.SATOSHI;
|
||||
Address refundAddress = new ECKey().toAddress(NETWORK_PARAMS);
|
||||
|
@ -69,7 +69,7 @@ public class PaymentSessionTest {
|
||||
// Send the payment and verify that the correct information is sent.
|
||||
// Add a dummy input to tx so it is considered valid.
|
||||
tx.addInput(new TransactionInput(PARAMS, tx, outputToMe.getScriptBytes()));
|
||||
ArrayList<Transaction> txns = new ArrayList<Transaction>();
|
||||
ArrayList<Transaction> txns = new ArrayList<>();
|
||||
txns.add(tx);
|
||||
Address refundAddr = new Address(PARAMS, serverKey.getPubKeyHash());
|
||||
paymentSession.sendPayment(txns, refundAddr, paymentMemo);
|
||||
@ -109,7 +109,7 @@ public class PaymentSessionTest {
|
||||
// Send the payment and verify that an exception is thrown.
|
||||
// Add a dummy input to tx so it is considered valid.
|
||||
tx.addInput(new TransactionInput(PARAMS, tx, outputToMe.getScriptBytes()));
|
||||
ArrayList<Transaction> txns = new ArrayList<Transaction>();
|
||||
ArrayList<Transaction> txns = new ArrayList<>();
|
||||
txns.add(tx);
|
||||
try {
|
||||
paymentSession.sendPayment(txns, null, null);
|
||||
@ -140,7 +140,7 @@ public class PaymentSessionTest {
|
||||
// Send the payment and verify that the correct information is sent.
|
||||
// Add a dummy input to tx so it is considered valid.
|
||||
tx.addInput(new TransactionInput(PARAMS, tx, outputToMe.getScriptBytes()));
|
||||
ArrayList<Transaction> txns = new ArrayList<Transaction>();
|
||||
ArrayList<Transaction> txns = new ArrayList<>();
|
||||
txns.add(tx);
|
||||
Address refundAddr = new Address(PARAMS, serverKey.getPubKeyHash());
|
||||
paymentSession.sendPayment(txns, refundAddr, paymentMemo);
|
||||
@ -187,7 +187,7 @@ public class PaymentSessionTest {
|
||||
}
|
||||
|
||||
private class MockPaymentSession extends PaymentSession {
|
||||
private ArrayList<PaymentLogItem> paymentLog = new ArrayList<PaymentLogItem>();
|
||||
private ArrayList<PaymentLogItem> paymentLog = new ArrayList<>();
|
||||
|
||||
public MockPaymentSession(Protos.PaymentRequest request) throws PaymentProtocolException {
|
||||
super(request);
|
||||
|
@ -90,7 +90,7 @@ public class ScriptTest {
|
||||
assertTrue(ScriptBuilder.createMultiSigOutputScript(2, keys).isSentToMultiSig());
|
||||
Script script = ScriptBuilder.createMultiSigOutputScript(3, keys);
|
||||
assertTrue(script.isSentToMultiSig());
|
||||
List<ECKey> pubkeys = new ArrayList<ECKey>(3);
|
||||
List<ECKey> pubkeys = new ArrayList<>(3);
|
||||
for (ECKey key : keys) pubkeys.add(ECKey.fromPublicOnly(key.getPubKeyPoint()));
|
||||
assertEquals(script.getPubKeys(), pubkeys);
|
||||
assertFalse(ScriptBuilder.createOutputScript(new ECKey()).isSentToMultiSig());
|
||||
@ -228,7 +228,7 @@ public class ScriptTest {
|
||||
tx.addInput(new TransactionInput(PARAMS, tx, new byte[] {}));
|
||||
Script script = new ScriptBuilder().smallNum(0).build();
|
||||
|
||||
LinkedList<byte[]> stack = new LinkedList<byte[]>();
|
||||
LinkedList<byte[]> stack = new LinkedList<>();
|
||||
Script.executeScript(tx, 0, script, stack, Script.ALL_VERIFY_FLAGS);
|
||||
assertEquals("OP_0 push length", 0, stack.get(0).length);
|
||||
}
|
||||
@ -321,7 +321,7 @@ public class ScriptTest {
|
||||
}
|
||||
|
||||
private Map<TransactionOutPoint, Script> parseScriptPubKeys(JsonNode inputs) throws IOException {
|
||||
Map<TransactionOutPoint, Script> scriptPubKeys = new HashMap<TransactionOutPoint, Script>();
|
||||
Map<TransactionOutPoint, Script> scriptPubKeys = new HashMap<>();
|
||||
for (JsonNode input : inputs) {
|
||||
String hash = input.get(0).asText();
|
||||
int index = input.get(1).asInt();
|
||||
@ -383,7 +383,7 @@ public class ScriptTest {
|
||||
|
||||
// Bitcoin Core checks this case in CheckTransaction, but we leave it to
|
||||
// later where we will see an attempt to double-spend, so we explicitly check here
|
||||
HashSet<TransactionOutPoint> set = new HashSet<TransactionOutPoint>();
|
||||
HashSet<TransactionOutPoint> set = new HashSet<>();
|
||||
for (TransactionInput input : transaction.getInputs()) {
|
||||
if (set.contains(input.getOutpoint()))
|
||||
valid = false;
|
||||
|
@ -233,7 +233,7 @@ public class WalletProtobufSerializerTest {
|
||||
|
||||
BlockChain chain = new BlockChain(PARAMS, myWallet, new MemoryBlockStore(PARAMS));
|
||||
|
||||
final ArrayList<Transaction> txns = new ArrayList<Transaction>(2);
|
||||
final ArrayList<Transaction> txns = new ArrayList<>(2);
|
||||
myWallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
|
@ -29,8 +29,8 @@ import java.util.concurrent.BlockingQueue;
|
||||
* An extension of {@link org.bitcoinj.core.PeerSocketHandler} that keeps inbound messages in a queue for later processing
|
||||
*/
|
||||
public abstract class InboundMessageQueuer extends PeerSocketHandler {
|
||||
public final BlockingQueue<Message> inboundMessages = new ArrayBlockingQueue<Message>(1000);
|
||||
public final Map<Long, SettableFuture<Void>> mapPingFutures = new HashMap<Long, SettableFuture<Void>>();
|
||||
public final BlockingQueue<Message> inboundMessages = new ArrayBlockingQueue<>(1000);
|
||||
public final Map<Long, SettableFuture<Void>> mapPingFutures = new HashMap<>();
|
||||
|
||||
public Peer peer;
|
||||
public BloomFilter lastReceivedFilter;
|
||||
|
@ -52,7 +52,7 @@ public class MockTransactionBroadcaster implements TransactionBroadcaster {
|
||||
}
|
||||
}
|
||||
|
||||
private final LinkedBlockingQueue<TxFuturePair> broadcasts = new LinkedBlockingQueue<TxFuturePair>();
|
||||
private final LinkedBlockingQueue<TxFuturePair> broadcasts = new LinkedBlockingQueue<>();
|
||||
|
||||
/** Sets this mock broadcaster on the given wallet. */
|
||||
public MockTransactionBroadcaster(Wallet wallet) {
|
||||
|
@ -59,7 +59,7 @@ public class TestWithNetworkConnections {
|
||||
|
||||
private NioServer[] peerServers = new NioServer[PEER_SERVERS];
|
||||
private final ClientConnectionManager channels;
|
||||
protected final BlockingQueue<InboundMessageQueuer> newPeerWriteTargetQueue = new LinkedBlockingQueue<InboundMessageQueuer>();
|
||||
protected final BlockingQueue<InboundMessageQueuer> newPeerWriteTargetQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
public enum ClientType {
|
||||
NIO_CLIENT_MANAGER,
|
||||
|
@ -44,7 +44,7 @@ public class BtcFormatTest {
|
||||
|
||||
@Parameters
|
||||
public static Set<Locale[]> data() {
|
||||
Set<Locale[]> localeSet = new HashSet<Locale[]>();
|
||||
Set<Locale[]> localeSet = new HashSet<>();
|
||||
for (Locale locale : Locale.getAvailableLocales()) {
|
||||
localeSet.add(new Locale[]{locale});
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class ExponentialBackoffTest {
|
||||
|
||||
@Test
|
||||
public void testInQueue() {
|
||||
PriorityQueue<ExponentialBackoff> queue = new PriorityQueue<ExponentialBackoff>();
|
||||
PriorityQueue<ExponentialBackoff> queue = new PriorityQueue<>();
|
||||
ExponentialBackoff backoff1 = new ExponentialBackoff(params);
|
||||
backoff.trackFailure();
|
||||
backoff.trackFailure();
|
||||
|
@ -50,7 +50,7 @@ public class BasicKeyChainTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
chain = new BasicKeyChain();
|
||||
onKeysAdded = new AtomicReference<List<ECKey>>();
|
||||
onKeysAdded = new AtomicReference<>();
|
||||
onKeysAddedRan = new AtomicBoolean();
|
||||
chain.addEventListener(new AbstractKeyChainEventListener() {
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public class DefaultCoinSelectorTest extends TestWithWallet {
|
||||
assertEquals(COIN, selection.valueGathered);
|
||||
|
||||
// Check we ordered them correctly (by depth).
|
||||
ArrayList<TransactionOutput> candidates = new ArrayList<TransactionOutput>();
|
||||
ArrayList<TransactionOutput> candidates = new ArrayList<>();
|
||||
candidates.add(t2.getOutput(0));
|
||||
candidates.add(t1.getOutput(0));
|
||||
DefaultCoinSelector.sortOutputs(candidates);
|
||||
@ -98,7 +98,7 @@ public class DefaultCoinSelectorTest extends TestWithWallet {
|
||||
Transaction t3 = checkNotNull(sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, CENT));
|
||||
|
||||
// Should be ordered t2, t1, t3.
|
||||
ArrayList<TransactionOutput> candidates = new ArrayList<TransactionOutput>();
|
||||
ArrayList<TransactionOutput> candidates = new ArrayList<>();
|
||||
candidates.add(t3.getOutput(0));
|
||||
candidates.add(t2.getOutput(0));
|
||||
candidates.add(t1.getOutput(0));
|
||||
|
@ -389,7 +389,7 @@ public class KeyChainGroupTest {
|
||||
public void events() throws Exception {
|
||||
// Check that events are registered with the right chains and that if a chain is added, it gets the event
|
||||
// listeners attached properly even post-hoc.
|
||||
final AtomicReference<ECKey> ran = new AtomicReference<ECKey>(null);
|
||||
final AtomicReference<ECKey> ran = new AtomicReference<>(null);
|
||||
final KeyChainEventListener listener = new KeyChainEventListener() {
|
||||
@Override
|
||||
public void onKeysAdded(List<ECKey> keys) {
|
||||
|
@ -563,7 +563,7 @@ public class WalletTest extends TestWithWallet {
|
||||
// Test that we correctly process transactions arriving from the chain, with callbacks for inbound and outbound.
|
||||
final Coin[] bigints = new Coin[4];
|
||||
final Transaction[] txn = new Transaction[2];
|
||||
final LinkedList<Transaction> confTxns = new LinkedList<Transaction>();
|
||||
final LinkedList<Transaction> confTxns = new LinkedList<>();
|
||||
wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
@ -813,7 +813,7 @@ public class WalletTest extends TestWithWallet {
|
||||
Transaction send3 = checkNotNull(wallet.createSend(OTHER_ADDRESS, value));
|
||||
wallet.commitTx(send3);
|
||||
assertEquals(ZERO, wallet.getBalance());
|
||||
final LinkedList<TransactionConfidence> dead = new LinkedList<TransactionConfidence>();
|
||||
final LinkedList<TransactionConfidence> dead = new LinkedList<>();
|
||||
final TransactionConfidence.Listener listener = new TransactionConfidence.Listener() {
|
||||
@Override
|
||||
public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) {
|
||||
@ -1218,7 +1218,7 @@ public class WalletTest extends TestWithWallet {
|
||||
Transaction send1c = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(0, 25)));
|
||||
wallet.commitTx(send1c);
|
||||
wallet.commitTx(send2);
|
||||
Set<Transaction> txns = new HashSet<Transaction>();
|
||||
Set<Transaction> txns = new HashSet<>();
|
||||
txns.add(send1);
|
||||
wallet.addTransactionsDependingOn(txns, wallet.getTransactions(true));
|
||||
assertEquals(3, txns.size());
|
||||
@ -1267,7 +1267,7 @@ public class WalletTest extends TestWithWallet {
|
||||
wallet.completeTx(req2c);
|
||||
Transaction send2c = req2c.tx;
|
||||
|
||||
Set<Transaction> unsortedTxns = new HashSet<Transaction>();
|
||||
Set<Transaction> unsortedTxns = new HashSet<>();
|
||||
unsortedTxns.add(send1a);
|
||||
unsortedTxns.add(send1b);
|
||||
unsortedTxns.add(send1c);
|
||||
@ -1710,7 +1710,7 @@ public class WalletTest extends TestWithWallet {
|
||||
|
||||
@Test
|
||||
public void removeWatchedAddresses() {
|
||||
List<Address> addressesForRemoval = new ArrayList<Address>();
|
||||
List<Address> addressesForRemoval = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Address watchedAddress = new ECKey().toAddress(PARAMS);
|
||||
addressesForRemoval.add(watchedAddress);
|
||||
@ -1735,7 +1735,7 @@ public class WalletTest extends TestWithWallet {
|
||||
|
||||
@Test
|
||||
public void removeScriptsBloomFilter() throws Exception {
|
||||
List<Address> addressesForRemoval = new ArrayList<Address>();
|
||||
List<Address> addressesForRemoval = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Address watchedAddress = new ECKey().toAddress(PARAMS);
|
||||
addressesForRemoval.add(watchedAddress);
|
||||
@ -3069,7 +3069,7 @@ public class WalletTest extends TestWithWallet {
|
||||
goodKey.setCreationTimeSeconds(Utils.currentTimeSeconds());
|
||||
|
||||
// Do an upgrade based on the bad key.
|
||||
final AtomicReference<List<DeterministicKeyChain>> fChains = new AtomicReference<List<DeterministicKeyChain>>();
|
||||
final AtomicReference<List<DeterministicKeyChain>> fChains = new AtomicReference<>();
|
||||
KeyChainGroup kcg = new KeyChainGroup(PARAMS) {
|
||||
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user