mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Remove useless math like >> 0.
This commit is contained in:
parent
b736b4f7b0
commit
c3c2916151
@ -38,7 +38,7 @@ public class TransactionOutputChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TransactionOutputChanges(InputStream in) throws IOException {
|
public TransactionOutputChanges(InputStream in) throws IOException {
|
||||||
int numOutsCreated = ((in.read() & 0xFF) << 0) |
|
int numOutsCreated = (in.read() & 0xFF) |
|
||||||
((in.read() & 0xFF) << 8) |
|
((in.read() & 0xFF) << 8) |
|
||||||
((in.read() & 0xFF) << 16) |
|
((in.read() & 0xFF) << 16) |
|
||||||
((in.read() & 0xFF) << 24);
|
((in.read() & 0xFF) << 24);
|
||||||
@ -46,7 +46,7 @@ public class TransactionOutputChanges {
|
|||||||
for (int i = 0; i < numOutsCreated; i++)
|
for (int i = 0; i < numOutsCreated; i++)
|
||||||
txOutsCreated.add(new UTXO(in));
|
txOutsCreated.add(new UTXO(in));
|
||||||
|
|
||||||
int numOutsSpent = ((in.read() & 0xFF) << 0) |
|
int numOutsSpent = (in.read() & 0xFF) |
|
||||||
((in.read() & 0xFF) << 8) |
|
((in.read() & 0xFF) << 8) |
|
||||||
((in.read() & 0xFF) << 16) |
|
((in.read() & 0xFF) << 16) |
|
||||||
((in.read() & 0xFF) << 24);
|
((in.read() & 0xFF) << 24);
|
||||||
@ -57,7 +57,7 @@ public class TransactionOutputChanges {
|
|||||||
|
|
||||||
public void serializeToStream(OutputStream bos) throws IOException {
|
public void serializeToStream(OutputStream bos) throws IOException {
|
||||||
int numOutsCreated = txOutsCreated.size();
|
int numOutsCreated = txOutsCreated.size();
|
||||||
bos.write(0xFF & (numOutsCreated >> 0));
|
bos.write(0xFF & numOutsCreated);
|
||||||
bos.write(0xFF & (numOutsCreated >> 8));
|
bos.write(0xFF & (numOutsCreated >> 8));
|
||||||
bos.write(0xFF & (numOutsCreated >> 16));
|
bos.write(0xFF & (numOutsCreated >> 16));
|
||||||
bos.write(0xFF & (numOutsCreated >> 24));
|
bos.write(0xFF & (numOutsCreated >> 24));
|
||||||
@ -66,7 +66,7 @@ public class TransactionOutputChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int numOutsSpent = txOutsSpent.size();
|
int numOutsSpent = txOutsSpent.size();
|
||||||
bos.write(0xFF & (numOutsSpent >> 0));
|
bos.write(0xFF & numOutsSpent);
|
||||||
bos.write(0xFF & (numOutsSpent >> 8));
|
bos.write(0xFF & (numOutsSpent >> 8));
|
||||||
bos.write(0xFF & (numOutsSpent >> 16));
|
bos.write(0xFF & (numOutsSpent >> 16));
|
||||||
bos.write(0xFF & (numOutsSpent >> 24));
|
bos.write(0xFF & (numOutsSpent >> 24));
|
||||||
|
@ -79,21 +79,21 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void uint32ToByteArrayBE(long val, byte[] out, int offset) {
|
public static void uint32ToByteArrayBE(long val, byte[] out, int offset) {
|
||||||
out[offset + 0] = (byte) (0xFF & (val >> 24));
|
out[offset] = (byte) (0xFF & (val >> 24));
|
||||||
out[offset + 1] = (byte) (0xFF & (val >> 16));
|
out[offset + 1] = (byte) (0xFF & (val >> 16));
|
||||||
out[offset + 2] = (byte) (0xFF & (val >> 8));
|
out[offset + 2] = (byte) (0xFF & (val >> 8));
|
||||||
out[offset + 3] = (byte) (0xFF & (val >> 0));
|
out[offset + 3] = (byte) (0xFF & val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uint32ToByteArrayLE(long val, byte[] out, int offset) {
|
public static void uint32ToByteArrayLE(long val, byte[] out, int offset) {
|
||||||
out[offset + 0] = (byte) (0xFF & (val >> 0));
|
out[offset] = (byte) (0xFF & val);
|
||||||
out[offset + 1] = (byte) (0xFF & (val >> 8));
|
out[offset + 1] = (byte) (0xFF & (val >> 8));
|
||||||
out[offset + 2] = (byte) (0xFF & (val >> 16));
|
out[offset + 2] = (byte) (0xFF & (val >> 16));
|
||||||
out[offset + 3] = (byte) (0xFF & (val >> 24));
|
out[offset + 3] = (byte) (0xFF & (val >> 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uint64ToByteArrayLE(long val, byte[] out, int offset) {
|
public static void uint64ToByteArrayLE(long val, byte[] out, int offset) {
|
||||||
out[offset + 0] = (byte) (0xFF & (val >> 0));
|
out[offset] = (byte) (0xFF & val);
|
||||||
out[offset + 1] = (byte) (0xFF & (val >> 8));
|
out[offset + 1] = (byte) (0xFF & (val >> 8));
|
||||||
out[offset + 2] = (byte) (0xFF & (val >> 16));
|
out[offset + 2] = (byte) (0xFF & (val >> 16));
|
||||||
out[offset + 3] = (byte) (0xFF & (val >> 24));
|
out[offset + 3] = (byte) (0xFF & (val >> 24));
|
||||||
@ -104,14 +104,14 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void uint32ToByteStreamLE(long val, OutputStream stream) throws IOException {
|
public static void uint32ToByteStreamLE(long val, OutputStream stream) throws IOException {
|
||||||
stream.write((int) (0xFF & (val >> 0)));
|
stream.write((int) (0xFF & val));
|
||||||
stream.write((int) (0xFF & (val >> 8)));
|
stream.write((int) (0xFF & (val >> 8)));
|
||||||
stream.write((int) (0xFF & (val >> 16)));
|
stream.write((int) (0xFF & (val >> 16)));
|
||||||
stream.write((int) (0xFF & (val >> 24)));
|
stream.write((int) (0xFF & (val >> 24)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void int64ToByteStreamLE(long val, OutputStream stream) throws IOException {
|
public static void int64ToByteStreamLE(long val, OutputStream stream) throws IOException {
|
||||||
stream.write((int) (0xFF & (val >> 0)));
|
stream.write((int) (0xFF & val));
|
||||||
stream.write((int) (0xFF & (val >> 8)));
|
stream.write((int) (0xFF & (val >> 8)));
|
||||||
stream.write((int) (0xFF & (val >> 16)));
|
stream.write((int) (0xFF & (val >> 16)));
|
||||||
stream.write((int) (0xFF & (val >> 24)));
|
stream.write((int) (0xFF & (val >> 24)));
|
||||||
@ -187,14 +187,14 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long readUint32(byte[] bytes, int offset) {
|
public static long readUint32(byte[] bytes, int offset) {
|
||||||
return ((bytes[offset++] & 0xFFL) << 0) |
|
return (bytes[offset++] & 0xFFL) |
|
||||||
((bytes[offset++] & 0xFFL) << 8) |
|
((bytes[offset++] & 0xFFL) << 8) |
|
||||||
((bytes[offset++] & 0xFFL) << 16) |
|
((bytes[offset++] & 0xFFL) << 16) |
|
||||||
((bytes[offset] & 0xFFL) << 24);
|
((bytes[offset] & 0xFFL) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long readInt64(byte[] bytes, int offset) {
|
public static long readInt64(byte[] bytes, int offset) {
|
||||||
return ((bytes[offset++] & 0xFFL) << 0) |
|
return (bytes[offset++] & 0xFFL) |
|
||||||
((bytes[offset++] & 0xFFL) << 8) |
|
((bytes[offset++] & 0xFFL) << 8) |
|
||||||
((bytes[offset++] & 0xFFL) << 16) |
|
((bytes[offset++] & 0xFFL) << 16) |
|
||||||
((bytes[offset++] & 0xFFL) << 24) |
|
((bytes[offset++] & 0xFFL) << 24) |
|
||||||
@ -205,10 +205,10 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long readUint32BE(byte[] bytes, int offset) {
|
public static long readUint32BE(byte[] bytes, int offset) {
|
||||||
return ((bytes[offset + 0] & 0xFFL) << 24) |
|
return ((bytes[offset] & 0xFFL) << 24) |
|
||||||
((bytes[offset + 1] & 0xFFL) << 16) |
|
((bytes[offset + 1] & 0xFFL) << 16) |
|
||||||
((bytes[offset + 2] & 0xFFL) << 8) |
|
((bytes[offset + 2] & 0xFFL) << 8) |
|
||||||
((bytes[offset + 3] & 0xFFL) << 0);
|
(bytes[offset + 3] & 0xFFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readUint16BE(byte[] bytes, int offset) {
|
public static int readUint16BE(byte[] bytes, int offset) {
|
||||||
@ -309,7 +309,7 @@ public class Utils {
|
|||||||
bytes[3] = (byte) size;
|
bytes[3] = (byte) size;
|
||||||
if (size >= 1) bytes[4] = (byte) ((compact >> 16) & 0xFF);
|
if (size >= 1) bytes[4] = (byte) ((compact >> 16) & 0xFF);
|
||||||
if (size >= 2) bytes[5] = (byte) ((compact >> 8) & 0xFF);
|
if (size >= 2) bytes[5] = (byte) ((compact >> 8) & 0xFF);
|
||||||
if (size >= 3) bytes[6] = (byte) ((compact >> 0) & 0xFF);
|
if (size >= 3) bytes[6] = (byte) (compact & 0xFF);
|
||||||
return decodeMPI(bytes, true);
|
return decodeMPI(bytes, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
|||||||
txOutChanges = bos.toByteArray();
|
txOutChanges = bos.toByteArray();
|
||||||
} else {
|
} else {
|
||||||
int numTxn = undoableBlock.getTransactions().size();
|
int numTxn = undoableBlock.getTransactions().size();
|
||||||
bos.write((int) (0xFF & (numTxn >> 0)));
|
bos.write((int) (0xFF & numTxn));
|
||||||
bos.write((int) (0xFF & (numTxn >> 8)));
|
bos.write((int) (0xFF & (numTxn >> 8)));
|
||||||
bos.write((int) (0xFF & (numTxn >> 16)));
|
bos.write((int) (0xFF & (numTxn >> 16)));
|
||||||
bos.write((int) (0xFF & (numTxn >> 24)));
|
bos.write((int) (0xFF & (numTxn >> 24)));
|
||||||
@ -805,7 +805,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
|||||||
StoredUndoableBlock block;
|
StoredUndoableBlock block;
|
||||||
if (txOutChanges == null) {
|
if (txOutChanges == null) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int numTxn = ((transactions[offset++] & 0xFF) << 0) |
|
int numTxn = ((transactions[offset++] & 0xFF)) |
|
||||||
((transactions[offset++] & 0xFF) << 8) |
|
((transactions[offset++] & 0xFF) << 8) |
|
||||||
((transactions[offset++] & 0xFF) << 16) |
|
((transactions[offset++] & 0xFF) << 16) |
|
||||||
((transactions[offset++] & 0xFF) << 24);
|
((transactions[offset++] & 0xFF) << 24);
|
||||||
|
@ -180,7 +180,7 @@ public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
|||||||
txOutChanges = bos.toByteArray();
|
txOutChanges = bos.toByteArray();
|
||||||
} else {
|
} else {
|
||||||
int numTxn = undoableBlock.getTransactions().size();
|
int numTxn = undoableBlock.getTransactions().size();
|
||||||
bos.write((int) (0xFF & (numTxn >> 0)));
|
bos.write((int) (0xFF & numTxn));
|
||||||
bos.write((int) (0xFF & (numTxn >> 8)));
|
bos.write((int) (0xFF & (numTxn >> 8)));
|
||||||
bos.write((int) (0xFF & (numTxn >> 16)));
|
bos.write((int) (0xFF & (numTxn >> 16)));
|
||||||
bos.write((int) (0xFF & (numTxn >> 24)));
|
bos.write((int) (0xFF & (numTxn >> 24)));
|
||||||
|
@ -158,7 +158,7 @@ public class FullBlockTestGenerator {
|
|||||||
outStream.write((int) (params.getPacketMagic() >>> 24));
|
outStream.write((int) (params.getPacketMagic() >>> 24));
|
||||||
outStream.write((int) (params.getPacketMagic() >>> 16));
|
outStream.write((int) (params.getPacketMagic() >>> 16));
|
||||||
outStream.write((int) (params.getPacketMagic() >>> 8));
|
outStream.write((int) (params.getPacketMagic() >>> 8));
|
||||||
outStream.write((int) (params.getPacketMagic() >>> 0));
|
outStream.write((int) params.getPacketMagic());
|
||||||
byte[] block = ((BlockAndValidity)element).block.bitcoinSerialize();
|
byte[] block = ((BlockAndValidity)element).block.bitcoinSerialize();
|
||||||
byte[] length = new byte[4];
|
byte[] length = new byte[4];
|
||||||
Utils.uint32ToByteArrayBE(block.length, length, 0);
|
Utils.uint32ToByteArrayBE(block.length, length, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user