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();
}
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"));
}
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"));
}
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"));
}
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());
}
Aggregations