mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-23 14:40:40 +01:00
ByteUtils: rename read helpers that read from streams
This commit is contained in:
parent
d89718aaf6
commit
7303043f37
4 changed files with 8 additions and 8 deletions
|
@ -418,7 +418,7 @@ public class ByteUtils {
|
|||
* Read 2 bytes from the stream as unsigned 16-bit integer in little endian format.
|
||||
* @param is stream to be read from
|
||||
*/
|
||||
public static int readUint16FromStream(InputStream is) {
|
||||
public static int readUint16(InputStream is) {
|
||||
byte[] buf = new byte[2];
|
||||
try {
|
||||
is.read(buf);
|
||||
|
@ -432,7 +432,7 @@ public class ByteUtils {
|
|||
* Read 4 bytes from the stream as unsigned 32-bit integer in little endian format.
|
||||
* @param is stream to be read from
|
||||
*/
|
||||
public static long readUint32FromStream(InputStream is) {
|
||||
public static long readUint32(InputStream is) {
|
||||
byte[] buf = new byte[4];
|
||||
try {
|
||||
is.read(buf);
|
||||
|
|
|
@ -40,12 +40,12 @@ public class TransactionOutputChanges {
|
|||
}
|
||||
|
||||
public TransactionOutputChanges(InputStream in) throws IOException {
|
||||
int numOutsCreated = (int) ByteUtils.readUint32FromStream(in);
|
||||
int numOutsCreated = (int) ByteUtils.readUint32(in);
|
||||
txOutsCreated = new LinkedList<>();
|
||||
for (int i = 0; i < numOutsCreated; i++)
|
||||
txOutsCreated.add(UTXO.fromStream(in));
|
||||
|
||||
int numOutsSpent = (int) ByteUtils.readUint32FromStream(in);
|
||||
int numOutsSpent = (int) ByteUtils.readUint32(in);
|
||||
txOutsSpent = new LinkedList<>();
|
||||
for (int i = 0; i < numOutsSpent; i++)
|
||||
txOutsSpent.add(UTXO.fromStream(in));
|
||||
|
|
|
@ -160,7 +160,7 @@ public class UTXO {
|
|||
throw new EOFException();
|
||||
Coin value = Coin.valueOf(ByteUtils.readInt64(valueBytes, 0));
|
||||
|
||||
int scriptBytesLength = (int) ByteUtils.readUint32FromStream(in);
|
||||
int scriptBytesLength = (int) ByteUtils.readUint32(in);
|
||||
byte[] scriptBytes = new byte[scriptBytesLength];
|
||||
if (in.read(scriptBytes) != scriptBytesLength)
|
||||
throw new EOFException();
|
||||
|
@ -176,7 +176,7 @@ public class UTXO {
|
|||
throw new EOFException();
|
||||
long index = ByteUtils.readUint32(indexBytes, 0);
|
||||
|
||||
int height = (int) ByteUtils.readUint32FromStream(in);
|
||||
int height = (int) ByteUtils.readUint32(in);
|
||||
|
||||
byte[] coinbaseByte = new byte[1];
|
||||
in.read(coinbaseByte);
|
||||
|
|
|
@ -368,12 +368,12 @@ public class Script {
|
|||
} else if (opcode == OP_PUSHDATA2) {
|
||||
// Read a short, then read that many bytes of data.
|
||||
if (bis.available() < 2) throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Unexpected end of script");
|
||||
dataToRead = ByteUtils.readUint16FromStream(bis);
|
||||
dataToRead = ByteUtils.readUint16(bis);
|
||||
} else if (opcode == OP_PUSHDATA4) {
|
||||
// Read a uint32, then read that many bytes of data.
|
||||
// Though this is allowed, because its value cannot be > 520, it should never actually be used
|
||||
if (bis.available() < 4) throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Unexpected end of script");
|
||||
dataToRead = ByteUtils.readUint32FromStream(bis);
|
||||
dataToRead = ByteUtils.readUint32(bis);
|
||||
}
|
||||
|
||||
ScriptChunk chunk;
|
||||
|
|
Loading…
Add table
Reference in a new issue