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

The following examples show how to use com.google.common.primitives.UnsignedInteger#fromIntBits() . 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: BinaryReaderTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadDWordBE() throws IOException {
    UnsignedInteger intValue = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 500);
    BinaryReader binaryReader = testBinaryReaderBuilder.putDWordBE(intValue).build();

    assertEquals(intValue, binaryReader.readDWordBE());
    assertEquals(4, binaryReader.getPosition());
}
 
Example 4
Source File: BinaryReaderTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadDWord() throws IOException {
    UnsignedInteger intValue = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 500);
    BinaryReader binaryReader = testBinaryReaderBuilder.putDWord(intValue).build();

    assertEquals(intValue, binaryReader.readDWord());
    assertEquals(4, binaryReader.getPosition());
}
 
Example 5
Source File: BinaryReaderTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadDWord() throws IOException {
    UnsignedInteger intValue = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 500);
    BinaryReader binaryReader = testBinaryReaderBuilder.putDWord(intValue).build();

    assertEquals(intValue, binaryReader.readDWord());
    assertEquals(4, binaryReader.getPosition());
}
 
Example 6
Source File: BinaryReaderTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadDWordBE() throws IOException {
    UnsignedInteger intValue = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 500);
    BinaryReader binaryReader = testBinaryReaderBuilder.putDWordBE(intValue).build();

    assertEquals(intValue, binaryReader.readDWordBE());
    assertEquals(4, binaryReader.getPosition());
}
 
Example 7
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 8
Source File: SizeTypeNodeTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testSizeTypeNodeDWord() throws IOException {
    UnsignedInteger value = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 132);
    assertEquals(value.toString(),
            new SizeTypeNode(testBinaryReaderBuilder.putDWord(value).build(), chunkHeader, parent, 4).getValue());
}
 
Example 9
Source File: transaction.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
public void set_reference_block(ripe_md160_object reference_block) {
    ref_block_num = new unsigned_short((short) bitutil.endian_reverse_u32(reference_block.hash[0]));
    ref_block_prefix = UnsignedInteger.fromIntBits(reference_block.hash[1]);
}
 
Example 10
Source File: BinaryReader.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Reads 4 bytes in big endian order and returns the UnsignedInteger value
 *
 * @return the value
 */
public UnsignedInteger readDWordBE() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, position, 4);
    position += 4;
    return UnsignedInteger.fromIntBits(byteBuffer.order(ByteOrder.BIG_ENDIAN).getInt());
}
 
Example 11
Source File: BinaryReader.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Reads 4 bytes in little endian order and returns the UnsignedInteger value
 *
 * @return the value
 */
public UnsignedInteger readDWord() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, position, 4);
    position += 4;
    return UnsignedInteger.fromIntBits(byteBuffer.order(ByteOrder.LITTLE_ENDIAN).getInt());
}
 
Example 12
Source File: IntBasedBsonObjectId.java    From mongowp with Apache License 2.0 4 votes vote down vote up
@Override
public UnsignedInteger getUnsignedTimestamp() {
  return UnsignedInteger.fromIntBits(timestamp);
}
 
Example 13
Source File: ByteArrayBsonObjectId.java    From mongowp with Apache License 2.0 4 votes vote down vote up
@Override
public UnsignedInteger getUnsignedTimestamp() {
  return UnsignedInteger.fromIntBits(getIntTimestamp());
}
 
Example 14
Source File: transaction.java    From bitshares_wallet with MIT License 4 votes vote down vote up
public void set_reference_block(ripemd160_object reference_block) {
    ref_block_num = new UnsignedShort((short)bitutil.endian_reverse_u32(reference_block.hash[0]));

    //ref_block_prefix = new UnsignedInteger(reference_block.hash[1]);
    ref_block_prefix = UnsignedInteger.fromIntBits(reference_block.hash[1]);
}
 
Example 15
Source File: SizeTypeNodeTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testSizeTypeNodeDWord() throws IOException {
    UnsignedInteger value = UnsignedInteger.fromIntBits(Integer.MAX_VALUE + 132);
    assertEquals(value.toString(),
            new SizeTypeNode(testBinaryReaderBuilder.putDWord(value).build(), chunkHeader, parent, 4).getValue());
}
 
Example 16
Source File: BinaryReader.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Reads 4 bytes in big endian order and returns the UnsignedInteger value
 *
 * @return the value
 */
public UnsignedInteger readDWordBE() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, position, 4);
    position += 4;
    return UnsignedInteger.fromIntBits(byteBuffer.order(ByteOrder.BIG_ENDIAN).getInt());
}
 
Example 17
Source File: BinaryReader.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Reads 4 bytes in little endian order and returns the UnsignedInteger value
 *
 * @return the value
 */
public UnsignedInteger readDWord() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, position, 4);
    position += 4;
    return UnsignedInteger.fromIntBits(byteBuffer.order(ByteOrder.LITTLE_ENDIAN).getInt());
}
 
Example 18
Source File: transaction.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public void set_reference_block(ripemd160_object reference_block) {
    ref_block_num = new UnsignedShort((short)bitutil.endian_reverse_u32(reference_block.hash[0]));

    //ref_block_prefix = new UnsignedInteger(reference_block.hash[1]);
    ref_block_prefix = UnsignedInteger.fromIntBits(reference_block.hash[1]);
}
 
Example 19
Source File: Uint32.java    From yangtools with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Convert this value to an {@link UnsignedInteger}.
 *
 * @return An UnsignedInteger instance
 */
public final UnsignedInteger toGuava() {
    return UnsignedInteger.fromIntBits(value);
}