BlockFileLoader, FullBlockTestGenerator: use readUint32()/writeInt32LE() rather than manually reversing bytes

This commit is contained in:
Sean Gilligan 2023-03-30 13:45:15 -07:00 committed by Andreas Schildbach
parent f0b69a405f
commit 90fc2bfb5e
2 changed files with 3 additions and 3 deletions

View File

@ -175,7 +175,7 @@ public class BlockFileLoader implements Iterable<Block>, Iterator<Block> {
}
byte[] bytes = new byte[4];
currentFileStream.read(bytes, 0, 4);
long size = ByteUtils.readUint32BE(ByteUtils.reverseBytes(bytes), 0);
long size = ByteUtils.readUint32(bytes, 0);
bytes = new byte[(int) size];
currentFileStream.read(bytes, 0, (int) size);
try {

View File

@ -195,8 +195,8 @@ public class FullBlockTestGenerator {
ByteUtils.writeInt32BE(params.getPacketMagic(), outStream);
byte[] block = ((BlockAndValidity) element).block.bitcoinSerialize();
byte[] length = new byte[4];
ByteUtils.writeInt32BE(block.length, length, 0);
outStream.write(ByteUtils.reverseBytes(length));
ByteUtils.writeInt32LE(block.length, length, 0);
outStream.write(length);
outStream.write(block);
((BlockAndValidity)element).block = null;
} catch (IOException e) {