forked from I2P_Developers/i2p.i2p
Cleanup: Don't use DataHelper.writeLong() for a single byte
This commit is contained in:
@ -45,7 +45,7 @@ public class AbuseSeverity extends DataStructureImpl {
|
||||
|
||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||
if (_severityId < 0) throw new DataFormatException("Invalid abuse severity: " + _severityId);
|
||||
DataHelper.writeLong(out, 1, _severityId);
|
||||
out.write((byte) _severityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,7 +105,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
||||
byte[] data = doWriteMessage();
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, data.length);
|
||||
DataHelper.writeLong(out, 1, getType());
|
||||
out.write((byte) getType());
|
||||
} catch (DataFormatException dfe) {
|
||||
throw new I2CPMessageException("Unable to write the message length or type", dfe);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
|
||||
int size = 2 + 4 + 4 + _payload.getSize();
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, size);
|
||||
DataHelper.writeLong(out, 1, MESSAGE_TYPE);
|
||||
out.write((byte) MESSAGE_TYPE);
|
||||
DataHelper.writeLong(out, 2, _sessionId);
|
||||
DataHelper.writeLong(out, 4, _messageId);
|
||||
DataHelper.writeLong(out, 4, _payload.getSize());
|
||||
|
@ -324,10 +324,10 @@ public class MessageStatusMessage extends I2CPMessageImpl {
|
||||
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, len);
|
||||
DataHelper.writeLong(out, 1, MESSAGE_TYPE);
|
||||
out.write((byte) MESSAGE_TYPE);
|
||||
DataHelper.writeLong(out, 2, _sessionId);
|
||||
DataHelper.writeLong(out, 4, _messageId);
|
||||
DataHelper.writeLong(out, 1, _status);
|
||||
out.write((byte) _status);
|
||||
DataHelper.writeLong(out, 4, _size);
|
||||
DataHelper.writeLong(out, 4, _nonce);
|
||||
} catch (DataFormatException dfe) {
|
||||
|
@ -86,7 +86,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
|
||||
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, len);
|
||||
DataHelper.writeLong(out, 1, MESSAGE_TYPE);
|
||||
out.write((byte) MESSAGE_TYPE);
|
||||
DataHelper.writeLong(out, 2, _sessionId);
|
||||
DataHelper.writeLong(out, 4, _messageId);
|
||||
} catch (DataFormatException dfe) {
|
||||
|
@ -117,7 +117,7 @@ public class SendMessageExpiresMessage extends SendMessageMessage {
|
||||
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, len);
|
||||
DataHelper.writeLong(out, 1, MESSAGE_TYPE);
|
||||
out.write((byte) MESSAGE_TYPE);
|
||||
_sessionId.writeBytes(out);
|
||||
_destination.writeBytes(out);
|
||||
_payload.writeBytes(out);
|
||||
|
@ -139,7 +139,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
||||
|
||||
try {
|
||||
DataHelper.writeLong(out, 4, len);
|
||||
DataHelper.writeLong(out, 1, getType());
|
||||
out.write((byte) getType());
|
||||
_sessionId.writeBytes(out);
|
||||
_destination.writeBytes(out);
|
||||
_payload.writeBytes(out);
|
||||
|
@ -430,7 +430,7 @@ public class DeliveryInstructions extends DataStructureImpl {
|
||||
// _log.debug("Write flags: " + flags + " mode: " + getDeliveryMode()
|
||||
// + " =?= " + flagMode(flags));
|
||||
byte additionalInfo[] = getAdditionalInfo();
|
||||
DataHelper.writeLong(out, 1, flags);
|
||||
out.write((byte) flags);
|
||||
if (additionalInfo != null) {
|
||||
out.write(additionalInfo);
|
||||
out.flush();
|
||||
|
@ -288,7 +288,7 @@ public class RouterAddress extends DataStructureImpl {
|
||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||
if (_transportStyle == null)
|
||||
throw new DataFormatException("uninitialized");
|
||||
DataHelper.writeLong(out, 1, _cost);
|
||||
out.write((byte) _cost);
|
||||
DataHelper.writeLong(out, 8, _expiration);
|
||||
DataHelper.writeString(out, _transportStyle);
|
||||
DataHelper.writeProperties(out, _options);
|
||||
|
@ -243,7 +243,7 @@ public class GarlicMessageBuilder {
|
||||
if (config instanceof PayloadGarlicConfig) {
|
||||
byte clove[] = buildClove(ctx, (PayloadGarlicConfig)config);
|
||||
baos = new ByteArrayOutputStream(clove.length + 16);
|
||||
DataHelper.writeLong(baos, 1, 1);
|
||||
baos.write((byte) 1);
|
||||
baos.write(clove);
|
||||
} else {
|
||||
byte cloves[][] = new byte[config.getCloveCount()][];
|
||||
@ -263,7 +263,7 @@ public class GarlicMessageBuilder {
|
||||
for (int i = 0; i < cloves.length; i++)
|
||||
len += cloves[i].length;
|
||||
baos = new ByteArrayOutputStream(len + 16);
|
||||
DataHelper.writeLong(baos, 1, cloves.length);
|
||||
baos.write((byte) cloves.length);
|
||||
for (int i = 0; i < cloves.length; i++)
|
||||
baos.write(cloves[i]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user