use of org.aion.rlp.RLPElement in project aion by aionnetwork.
the class ResBlocksBodies method decode.
public static ResBlocksBodies decode(final byte[] _msgBytes) {
RLPList paramsList = (RLPList) RLP.decode2(_msgBytes).get(0);
List<byte[]> blocksBodies = new ArrayList<>();
for (RLPElement aParamsList : paramsList) {
RLPList rlpData = ((RLPList) aParamsList);
blocksBodies.add(rlpData.getRLPData());
}
return new ResBlocksBodies(blocksBodies);
}
use of org.aion.rlp.RLPElement in project aion by aionnetwork.
the class AionBlkWrapper method parse.
@Override
protected void parse(byte[] bytes) {
List<RLPElement> params = RLP.decode2(bytes);
List<RLPElement> wrapper = (RLPList) params.get(0);
byte[] blockBytes = wrapper.get(0).getRLPData();
byte[] importFailedBytes = wrapper.get(1).getRLPData();
byte[] receivedAtBytes = wrapper.get(2).getRLPData();
byte[] newBlockBytes = wrapper.get(3).getRLPData();
this.block = new AionBlock(blockBytes);
this.importFailedAt = importFailedBytes == null ? 0 : new BigInteger(1, importFailedBytes).longValue();
this.receivedAt = receivedAtBytes == null ? 0 : new BigInteger(1, receivedAtBytes).longValue();
byte newBlock = newBlockBytes == null ? 0 : new BigInteger(1, newBlockBytes).byteValue();
this.newBlock = newBlock == 1;
this.nodeId = wrapper.get(4).getRLPData();
}
use of org.aion.rlp.RLPElement in project aion by aionnetwork.
the class AionBlock method parseTxs.
private void parseTxs(RLPList txTransactions) {
this.txsState = new TrieImpl(null);
for (int i = 0; i < txTransactions.size(); i++) {
RLPElement transactionRaw = txTransactions.get(i);
this.transactionsList.add(new AionTransaction(transactionRaw.getRLPData()));
this.txsState.update(RLP.encodeInt(i), transactionRaw.getRLPData());
}
}
use of org.aion.rlp.RLPElement in project aion by aionnetwork.
the class AionTxExecSummary method decodeStorageDiff.
private static Map<DataWord, DataWord> decodeStorageDiff(RLPList storageDiff) {
Map<DataWord, DataWord> result = new HashMap<>();
for (RLPElement entry : storageDiff) {
DataWord key = new DataWord(((RLPList) entry).get(0).getRLPData());
DataWord value = new DataWord(((RLPList) entry).get(1).getRLPData());
result.put(key, value);
}
return result;
}
use of org.aion.rlp.RLPElement in project aion by aionnetwork.
the class AionTxExecSummary method decodeTouchedStorage.
protected static TxTouchedStorage decodeTouchedStorage(RLPElement encoded) {
TxTouchedStorage result = new TxTouchedStorage();
for (RLPElement entry : (RLPList) encoded) {
RLPList asList = (RLPList) entry;
DataWord key = new DataWord(asList.get(0).getRLPData());
DataWord value = new DataWord(asList.get(1).getRLPData());
byte[] changedBytes = asList.get(2).getRLPData();
boolean changed = isNotEmpty(changedBytes) && RLP.decodeInt(changedBytes, 0) == 1;
result.add(new TxTouchedStorage.Entry(key, value, changed));
}
return result;
}
Aggregations