Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Remove RlpUtils #285

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.ethereum.p2p.wire.RawMessage;
import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RlpUtils;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.io.IOException;
Expand All @@ -44,7 +44,8 @@ public void blockBodiesRoundTrip() throws IOException {
final ByteBuffer buffer =
ByteBuffer.wrap(Resources.toByteArray(Resources.getResource("50.blocks")));
for (int i = 0; i < 50; ++i) {
final byte[] block = new byte[RlpUtils.decodeLength(buffer, 0)];
final int blockSize = RLP.calculateSize(BytesValue.wrapBuffer(buffer));
final byte[] block = new byte[blockSize];
buffer.get(block);
buffer.compact().position(0);
final RLPInput oneBlock = new BytesValueRLPInput(BytesValue.wrap(block), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.ethereum.p2p.wire.RawMessage;
import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RlpUtils;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.io.IOException;
Expand All @@ -42,7 +42,8 @@ public void blockHeadersRoundTrip() throws IOException {
final ByteBuffer buffer =
ByteBuffer.wrap(Resources.toByteArray(Resources.getResource("50.blocks")));
for (int i = 0; i < 50; ++i) {
final byte[] block = new byte[RlpUtils.decodeLength(buffer, 0)];
final int blockSize = RLP.calculateSize(BytesValue.wrapBuffer(buffer));
final byte[] block = new byte[blockSize];
buffer.get(block);
buffer.compact().position(0);
final RLPInput oneBlock = new BytesValueRLPInput(BytesValue.wrap(block), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.ethereum.p2p.wire.RawMessage;
import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RlpUtils;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.io.IOException;
Expand All @@ -41,7 +41,8 @@ public void getBlockBodiesRoundTrip() throws IOException {
final ByteBuffer buffer =
ByteBuffer.wrap(Resources.toByteArray(Resources.getResource("50.blocks")));
for (int i = 0; i < 50; ++i) {
final byte[] block = new byte[RlpUtils.decodeLength(buffer, 0)];
final int blockSize = RLP.calculateSize(BytesValue.wrapBuffer(buffer));
final byte[] block = new byte[blockSize];
buffer.get(block);
buffer.compact().position(0);
final RLPInput oneBlock = new BytesValueRLPInput(BytesValue.wrap(block), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.ethereum.p2p.wire.RawMessage;
import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RlpUtils;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.io.IOException;
Expand All @@ -40,7 +40,8 @@ public void blockHeadersRoundTrip() throws IOException {
final ByteBuffer buffer =
ByteBuffer.wrap(Resources.toByteArray(Resources.getResource("50.blocks")));
for (int i = 0; i < 50; ++i) {
final byte[] block = new byte[RlpUtils.decodeLength(buffer, 0)];
final int blockSize = RLP.calculateSize(BytesValue.wrapBuffer(buffer));
final byte[] block = new byte[blockSize];
buffer.get(block);
buffer.compact().position(0);
final RLPInput oneBlock = new BytesValueRLPInput(BytesValue.wrap(block), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import tech.pegasys.pantheon.ethereum.p2p.rlpx.handshake.HandshakeSecrets;
import tech.pegasys.pantheon.ethereum.p2p.wire.RawMessage;
import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RlpUtils;
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.util.Arrays;
Expand Down Expand Up @@ -199,7 +198,7 @@ private int processHeader(final ByteBuf tainedHeader) throws FramingException {

// Discard the header data (RLP): being set to fixed value 0xc28080 (list of two null
// elements) by other clients.
final int headerDataLength = RlpUtils.decodeLength(h.nioBuffer(), 0);
final int headerDataLength = RLP.calculateSize(BytesValue.wrapBuffer(h.nioBuffer()));
h.skipBytes(headerDataLength);

// Discard padding in header (= zero-fill to 16-byte boundary).
Expand Down

This file was deleted.