Java Code Examples for com.google.common.primitives.UnsignedInteger#compareTo()

The following examples show how to use com.google.common.primitives.UnsignedInteger#compareTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transaction.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the minimum nSequence number of all inputs
 * Can be used to detect transactions marked for Full-RBF and thus are very low trust while having 0 conf
 * Transactions with minSequenceNumber < MAX_INT-1 are eligible for full RBF
 * https://github.com/bitcoin/bitcoin/pull/6871#event-476297575
 *
 * @return the min nSequence of all inputs of that transaction
 */
public UnsignedInteger getMinSequenceNumber() {
   UnsignedInteger minVal = UnsignedInteger.MAX_VALUE;
   for (TransactionInput input : inputs) {
      UnsignedInteger nSequence = UnsignedInteger.fromIntBits(input.sequence);
      if (nSequence.compareTo(minVal) < 0) {
         minVal = nSequence;
      }
   }
   return minVal;
}
 
Example 2
Source File: Transaction.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the minimum nSequence number of all inputs
 * Can be used to detect transactions marked for Full-RBF and thus are very low trust while having 0 conf
 * Transactions with minSequenceNumber < MAX_INT-1 are eligible for full RBF
 * https://github.com/bitcoin/bitcoin/pull/6871#event-476297575
 *
 * @return the min nSequence of all inputs of that transaction
 */
public UnsignedInteger getMinSequenceNumber() {
   UnsignedInteger minVal = UnsignedInteger.MAX_VALUE;
   for (TransactionInput input : inputs) {
      UnsignedInteger nSequence = UnsignedInteger.fromIntBits(input.sequence);
      if (nSequence.compareTo(minVal) < 0) {
         minVal = nSequence;
      }
   }
   return minVal;
}
 
Example 3
Source File: Transaction.java    From bitshares_wallet with MIT License 5 votes vote down vote up
/**
 * Returns the minimum nSequence number of all inputs
 * Can be used to detect transactions marked for Full-RBF and thus are very low trust while having 0 conf
 * Transactions with minSequenceNumber < MAX_INT-1 are eligible for full RBF
 * https://github.com/bitcoin/bitcoin/pull/6871#event-476297575
 *
 * @return the min nSequence of all inputs of that transaction
 */
public UnsignedInteger getMinSequenceNumber() {
   UnsignedInteger minVal = UnsignedInteger.MAX_VALUE;
   for (TransactionInput input : inputs) {
      UnsignedInteger nSequence = UnsignedInteger.fromIntBits(input.sequence);
      if (nSequence.compareTo(minVal) < 0) {
         minVal = nSequence;
      }
   }
   return minVal;
}
 
Example 4
Source File: NumberUtil.java    From localization_nifi with Apache License 2.0 3 votes vote down vote up
/**
 * Throws an exception if the UnsignedInteger is greater than a given int, returning the int value otherwise
 *
 * @param unsignedInteger the number
 * @param max             the maximum value
 * @param errorMessage    error message (can be Java format string)
 * @param args            args for error message format string
 * @return the value
 * @throws IOException if the value is greater than max
 */
public static int intValueMax(UnsignedInteger unsignedInteger, int max, String errorMessage, Object... args) throws IOException {
    if (unsignedInteger.compareTo(UnsignedInteger.valueOf(max)) > 0) {
        throw createException(errorMessage, args, "< " + max, unsignedInteger);
    }
    return unsignedInteger.intValue();
}
 
Example 5
Source File: NumberUtil.java    From nifi with Apache License 2.0 3 votes vote down vote up
/**
 * Throws an exception if the UnsignedInteger is greater than a given int, returning the int value otherwise
 *
 * @param unsignedInteger the number
 * @param max             the maximum value
 * @param errorMessage    error message (can be Java format string)
 * @param args            args for error message format string
 * @return the value
 * @throws IOException if the value is greater than max
 */
public static int intValueMax(UnsignedInteger unsignedInteger, int max, String errorMessage, Object... args) throws IOException {
    if (unsignedInteger.compareTo(UnsignedInteger.valueOf(max)) > 0) {
        throw createException(errorMessage, args, "< " + max, unsignedInteger);
    }
    return unsignedInteger.intValue();
}