forked from Qortal/qortal
Added networking optimization, to avoid wasted processing on every read.
Thanks to @catbref for finding this.
This commit is contained in:
parent
b30445c5f8
commit
25efee55b8
@ -473,16 +473,18 @@ public class Peer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytesRead > 0) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
byte[] leadingBytes = new byte[Math.min(bytesRead, 8)];
|
if (bytesRead > 0) {
|
||||||
this.byteBuffer.asReadOnlyBuffer().position(priorPosition).get(leadingBytes);
|
byte[] leadingBytes = new byte[Math.min(bytesRead, 8)];
|
||||||
String leadingHex = HashCode.fromBytes(leadingBytes).toString();
|
this.byteBuffer.asReadOnlyBuffer().position(priorPosition).get(leadingBytes);
|
||||||
|
String leadingHex = HashCode.fromBytes(leadingBytes).toString();
|
||||||
|
|
||||||
LOGGER.trace("[{}] Received {} bytes, starting {}, into byteBuffer[{}] from peer {}",
|
LOGGER.trace("[{}] Received {} bytes, starting {}, into byteBuffer[{}] from peer {}",
|
||||||
this.peerConnectionId, bytesRead, leadingHex, priorPosition, this);
|
this.peerConnectionId, bytesRead, leadingHex, priorPosition, this);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.trace("[{}] Received {} bytes into byteBuffer[{}] from peer {}", this.peerConnectionId,
|
LOGGER.trace("[{}] Received {} bytes into byteBuffer[{}] from peer {}", this.peerConnectionId,
|
||||||
bytesRead, priorPosition, this);
|
bytesRead, priorPosition, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final boolean wasByteBufferFull = !this.byteBuffer.hasRemaining();
|
final boolean wasByteBufferFull = !this.byteBuffer.hasRemaining();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user