Search in sources :

Example 16 with RLPInput

use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.

the class ByteCodesMessage method bytecodes.

public ByteCodes bytecodes(final boolean withRequestId) {
    final ArrayDeque<Bytes> codes = new ArrayDeque<>();
    final RLPInput input = new BytesValueRLPInput(data, false);
    input.enterList();
    if (withRequestId)
        input.skipNext();
    input.enterList();
    while (!input.isEndOfCurrentList()) {
        codes.add(input.readBytes());
    }
    input.leaveList();
    input.leaveList();
    return ImmutableByteCodes.builder().codes(codes).build();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) RLPInput(org.hyperledger.besu.ethereum.rlp.RLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) ArrayDeque(kotlin.collections.ArrayDeque)

Example 17 with RLPInput

use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.

the class GetAccountRangeMessage method range.

public Range range(final boolean withRequestId) {
    final RLPInput input = new BytesValueRLPInput(data, false);
    input.enterList();
    if (withRequestId)
        input.skipNext();
    final Hash worldStateRootHash = Hash.wrap(Bytes32.wrap(input.readBytes32()));
    final ImmutableRange range = ImmutableRange.builder().worldStateRootHash(getRootHash().orElse(worldStateRootHash)).startKeyHash(Hash.wrap(Bytes32.wrap(input.readBytes32()))).endKeyHash(Hash.wrap(Bytes32.wrap(input.readBytes32()))).responseBytes(input.readBigIntegerScalar()).build();
    input.leaveList();
    return range;
}
Also used : RLPInput(org.hyperledger.besu.ethereum.rlp.RLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) Hash(org.hyperledger.besu.datatypes.Hash) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput)

Example 18 with RLPInput

use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.

the class GetReceiptsMessage method hashes.

public Iterable<Hash> hashes() {
    final RLPInput input = new BytesValueRLPInput(data, false);
    input.enterList();
    final Collection<Hash> hashes = new ArrayList<>();
    while (!input.isEndOfCurrentList()) {
        hashes.add(Hash.wrap(input.readBytes32()));
    }
    input.leaveList();
    return hashes;
}
Also used : RLPInput(org.hyperledger.besu.ethereum.rlp.RLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) ArrayList(java.util.ArrayList) Hash(org.hyperledger.besu.datatypes.Hash) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput)

Example 19 with RLPInput

use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.

the class StorageRangeMessage method slotsData.

public SlotRangeData slotsData(final boolean withRequestId) {
    final ArrayDeque<TreeMap<Bytes32, Bytes>> slots = new ArrayDeque<>();
    final ArrayDeque<Bytes> proofs = new ArrayDeque<>();
    final RLPInput input = new BytesValueRLPInput(data, false);
    input.enterList();
    if (withRequestId)
        input.skipNext();
    input.readList(accountRlpInput -> {
        slots.add(new TreeMap<>());
        return accountRlpInput.readList(slotRlpInput -> {
            slotRlpInput.enterList();
            slots.last().put(slotRlpInput.readBytes32(), slotRlpInput.readBytes());
            slotRlpInput.leaveList();
            // we don't need the response
            return Void.TYPE;
        });
    });
    input.enterList();
    while (!input.isEndOfCurrentList()) {
        proofs.add(input.readBytes());
    }
    input.leaveList();
    input.leaveList();
    return ImmutableSlotRangeData.builder().slots(slots).proofs(proofs).build();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) RLPInput(org.hyperledger.besu.ethereum.rlp.RLPInput) TreeMap(java.util.TreeMap) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) ArrayDeque(kotlin.collections.ArrayDeque)

Example 20 with RLPInput

use of org.hyperledger.besu.ethereum.rlp.RLPInput in project besu by hyperledger.

the class TrieNodesMessage method nodes.

public ArrayDeque<Bytes> nodes(final boolean withRequestId) {
    final ArrayDeque<Bytes> trieNodes = new ArrayDeque<>();
    final RLPInput input = new BytesValueRLPInput(data, false);
    input.enterList();
    if (withRequestId)
        input.skipNext();
    input.enterList();
    while (!input.isEndOfCurrentList()) {
        trieNodes.add(input.readBytes());
    }
    input.leaveList();
    input.leaveList();
    return trieNodes;
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) RLPInput(org.hyperledger.besu.ethereum.rlp.RLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) BytesValueRLPInput(org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput) ArrayDeque(kotlin.collections.ArrayDeque)

Aggregations

RLPInput (org.hyperledger.besu.ethereum.rlp.RLPInput)68 BytesValueRLPInput (org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput)34 Bytes (org.apache.tuweni.bytes.Bytes)24 Test (org.junit.Test)21 BytesValueRLPOutput (org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput)15 Hash (org.hyperledger.besu.datatypes.Hash)12 ArrayList (java.util.ArrayList)11 SECPSignature (org.hyperledger.besu.crypto.SECPSignature)11 Block (org.hyperledger.besu.ethereum.core.Block)9 BigInteger (java.math.BigInteger)8 Address (org.hyperledger.besu.datatypes.Address)8 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)7 Transaction (org.hyperledger.besu.ethereum.core.Transaction)7 ArrayDeque (kotlin.collections.ArrayDeque)6 Bytes32 (org.apache.tuweni.bytes.Bytes32)6 ByteBuffer (java.nio.ByteBuffer)5 Optional (java.util.Optional)5 Wei (org.hyperledger.besu.datatypes.Wei)5 MainnetBlockHeaderFunctions (org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions)5 MessageData (org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData)5