Search in sources :

Example 1 with RLPItem

use of org.ethereum.util.RLPItem in project rskj by rsksmart.

the class FindNodePeerMessage method parse.

@Override
public final void parse(byte[] data) {
    RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
    RLPItem chk = (RLPItem) dataList.get(1);
    this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
    RLPItem nodeRlp = (RLPItem) dataList.get(0);
    this.nodeId = nodeRlp.getRLPData();
}
Also used : RLPItem(org.ethereum.util.RLPItem) RLPList(org.ethereum.util.RLPList)

Example 2 with RLPItem

use of org.ethereum.util.RLPItem in project rskj by rsksmart.

the class PingPeerMessage method parse.

@Override
public final void parse(byte[] data) {
    RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
    RLPList fromList = (RLPList) dataList.get(1);
    RLPItem chk = (RLPItem) dataList.get(2);
    byte[] ipB = fromList.get(0).getRLPData();
    this.host = new String(ipB, Charset.forName("UTF-8"));
    this.port = ByteUtil.byteArrayToInt(fromList.get(1).getRLPData());
    this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
}
Also used : RLPItem(org.ethereum.util.RLPItem) RLPList(org.ethereum.util.RLPList)

Example 3 with RLPItem

use of org.ethereum.util.RLPItem in project rskj by rsksmart.

the class NeighborsPeerMessage method parse.

@Override
public final void parse(byte[] data) {
    RLPList list = (RLPList) RLP.decode2OneItem(data, 0);
    RLPList nodesRLP = (RLPList) list.get(0);
    nodes = new ArrayList<>();
    for (int i = 0; i < nodesRLP.size(); ++i) {
        RLPList nodeRLP = (RLPList) nodesRLP.get(i);
        Node node = new Node(nodeRLP.getRLPData());
        nodes.add(node);
    }
    RLPItem chk = (RLPItem) list.get(1);
    this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
}
Also used : RLPItem(org.ethereum.util.RLPItem) Node(org.ethereum.net.rlpx.Node) RLPList(org.ethereum.util.RLPList)

Example 4 with RLPItem

use of org.ethereum.util.RLPItem in project rskj by rsksmart.

the class PongPeerMessage method parse.

@Override
public final void parse(byte[] data) {
    RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
    RLPList fromList = (RLPList) dataList.get(1);
    byte[] ipB = fromList.get(0).getRLPData();
    this.host = new String(ipB, Charset.forName("UTF-8"));
    this.port = ByteUtil.byteArrayToInt(fromList.get(1).getRLPData());
    RLPItem chk = (RLPItem) dataList.get(2);
    this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
}
Also used : RLPItem(org.ethereum.util.RLPItem) RLPList(org.ethereum.util.RLPList)

Example 5 with RLPItem

use of org.ethereum.util.RLPItem in project rskj by rsksmart.

the class ContractDetailsImpl method decode.

@Override
public final void decode(byte[] rlpBytes) {
    ArrayList<RLPElement> rlpData = RLP.decode2(rlpBytes);
    RLPList rlpList = (RLPList) rlpData.get(0);
    RLPItem rlpAddress = (RLPItem) rlpList.get(0);
    RLPItem rlpIsExternalStorage = (RLPItem) rlpList.get(1);
    RLPItem rlpStorage = (RLPItem) rlpList.get(2);
    RLPElement rlpCode = rlpList.get(3);
    RLPList rlpKeys = (RLPList) rlpList.get(4);
    this.address = rlpAddress.getRLPData();
    this.externalStorage = rlpIsExternalStorage.getRLPData() != null;
    this.originalExternalStorage = this.externalStorage;
    if (this.externalStorage) {
        Keccak256 snapshotHash = new Keccak256(rlpStorage.getRLPData());
        this.trie = new TrieImpl(new TrieStoreImpl(levelDbByName(config, getDataSourceName())), true).getSnapshotTo(snapshotHash);
    } else {
        this.trie = TrieImpl.deserialize(rlpStorage.getRLPData());
    }
    this.code = (rlpCode.getRLPData() == null) ? EMPTY_BYTE_ARRAY : rlpCode.getRLPData();
    for (RLPElement key : rlpKeys) {
        addKey(key.getRLPData());
    }
    logger.trace("decoding contract details from bytes, hash {}, address {}, storage size {}, has external storage {}", this.getStorageHashAsString(), this.getAddressAsString(), this.getStorageSize(), this.hasExternalStorage());
}
Also used : RLPItem(org.ethereum.util.RLPItem) RLPElement(org.ethereum.util.RLPElement) Keccak256(co.rsk.crypto.Keccak256) RLPList(org.ethereum.util.RLPList)

Aggregations

RLPItem (org.ethereum.util.RLPItem)5 RLPList (org.ethereum.util.RLPList)5 Keccak256 (co.rsk.crypto.Keccak256)1 Node (org.ethereum.net.rlpx.Node)1 RLPElement (org.ethereum.util.RLPElement)1