mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
BlockFileLoader: effectively final sizeBytes
, dataBytes
When reading blocks from the file stream use two effectively final `byte[]` rather than reuse a single `byte[]`. This also makes the code more readable by using more meaningful variable names.
This commit is contained in:
parent
7776f7c907
commit
2248513489
@ -164,13 +164,13 @@ public class BlockFileLoader implements Iterable<Block> {
|
||||
if (nextChar == (packetMagic & 0xff))
|
||||
break;
|
||||
}
|
||||
byte[] bytes = new byte[4];
|
||||
currentFileStream.read(bytes, 0, 4);
|
||||
long size = ByteUtils.readUint32(bytes, 0);
|
||||
bytes = new byte[(int) size];
|
||||
currentFileStream.read(bytes, 0, (int) size);
|
||||
byte[] sizeBytes = new byte[4];
|
||||
currentFileStream.read(sizeBytes, 0, 4);
|
||||
long size = ByteUtils.readUint32(sizeBytes, 0);
|
||||
byte[] dataBytes = new byte[(int) size];
|
||||
currentFileStream.read(dataBytes, 0, (int) size);
|
||||
try {
|
||||
nextBlock = serializer.makeBlock(ByteBuffer.wrap(bytes));
|
||||
nextBlock = serializer.makeBlock(ByteBuffer.wrap(dataBytes));
|
||||
} catch (ProtocolException e) {
|
||||
nextBlock = null;
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user