private boolean checkForDoubleSpendAgainstPending(Transaction tx,boolean takeAction){
  checkState(lock.isHeldByCurrentThread());
  HashSet<TransactionOutPoint> outpoints=new HashSet<TransactionOutPoint>();
  for (  TransactionInput input : tx.getInputs()) {
    outpoints.add(input.getOutpoint());
  }
  LinkedList<Transaction> doubleSpentTxns=Lists.newLinkedList();
  for (  Transaction p : pending.values()) {
    for (    TransactionInput input : p.getInputs()) {
      TransactionOutPoint outpoint=input.getOutpoint();
      if (outpoints.contains(outpoint)) {
        if (!doubleSpentTxns.isEmpty() && doubleSpentTxns.getLast() == p)         continue;
        doubleSpentTxns.add(p);
      }
    }
  }
  if (takeAction && !doubleSpentTxns.isEmpty()) {
    killTx(tx,doubleSpentTxns);
  }
  return !doubleSpentTxns.isEmpty();
}

private boolean checkForDoubleSpendAgainstPending ( Transaction tx , boolean takeAction ) { checkState ( lock . isHeldByCurrentThread ( ) ) ; HashSet < TransactionOutPoint > outpoints = new HashSet < TransactionOutPoint > ( ) ; for ( TransactionInput input : tx . getInputs ( ) ) { outpoints . add ( input . getOutpoint ( ) ) ; } LinkedList < Transaction > doubleSpentTxns = Lists . newLinkedList ( ) ; for ( Transaction p : pending . values ( ) ) { for ( TransactionInput input : p . getInputs ( ) ) { TransactionOutPoint outpoint = input . getOutpoint ( ) ; if ( outpoints . contains ( outpoint ) ) { if ( ! doubleSpentTxns . isEmpty ( ) && doubleSpentTxns . getLast ( ) == p ) continue ; doubleSpentTxns . add ( p ) ; } } } if ( takeAction && ! doubleSpentTxns . isEmpty ( ) ) { killTx ( tx , doubleSpentTxns ) ; } return ! doubleSpentTxns . isEmpty ( ) ; }
checks if " tx " is spending any inputs of pending transactions . not a general check , but it can work even if the double spent inputs are not ours . returns the pending tx that was double spent or null if none found .
