use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class TrieImpl method deserialize.
public void deserialize(byte[] data) {
synchronized (cache) {
RLPList rlpList = (RLPList) RLP.decode2(data).get(0);
RLPItem keysElement = (RLPItem) rlpList.get(0);
RLPList valsList = (RLPList) rlpList.get(1);
RLPItem root = (RLPItem) rlpList.get(2);
for (int i = 0; i < valsList.size(); ++i) {
byte[] val = valsList.get(i).getRLPData();
byte[] key = new byte[32];
Value value = Value.fromRlpEncoded(val);
System.arraycopy(keysElement.getRLPData(), i * 32, key, 0, 32);
cache.getNodes().put(wrap(key), new Node(value));
}
this.deserializeRoot(root.getRLPData());
}
}
use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class KdfParams method parse.
public static KdfParams parse(byte[] bytes) throws UnsupportedEncodingException {
RLPList list = (RLPList) RLP.decode2(bytes).get(0);
KdfParams kdfParams = new KdfParams();
kdfParams.setC(ByteUtil.byteArrayToInt(list.get(0).getRLPData()));
kdfParams.setDklen(ByteUtil.byteArrayToInt(list.get(1).getRLPData()));
kdfParams.setN(ByteUtil.byteArrayToInt(list.get(2).getRLPData()));
kdfParams.setP(ByteUtil.byteArrayToInt(list.get(3).getRLPData()));
kdfParams.setR(ByteUtil.byteArrayToInt(list.get(4).getRLPData()));
kdfParams.setSalt(new String(list.get(5).getRLPData(), "US-ASCII"));
return kdfParams;
}
use of org.aion.rlp.RLPList 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.RLPList 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.RLPList in project aion by aionnetwork.
the class AionInternalTx method rlpParse.
@Override
public void rlpParse() {
RLPList decodedTxList = RLP.decode2(rlpEncoded);
RLPList transaction = (RLPList) decodedTxList.get(0);
int rlpIdx = 0;
this.nonce = transaction.get(rlpIdx++).getRLPData();
this.parentHash = transaction.get(rlpIdx++).getRLPData();
this.from = Address.wrap(transaction.get(rlpIdx++).getRLPData());
this.to = Address.wrap(transaction.get(rlpIdx++).getRLPData());
this.value = transaction.get(rlpIdx++).getRLPData();
// TODO: check the order
this.data = transaction.get(rlpIdx++).getRLPData();
this.note = new String(transaction.get(rlpIdx++).getRLPData());
this.deep = decodeInt(transaction.get(rlpIdx++).getRLPData());
this.index = decodeInt(transaction.get(rlpIdx++).getRLPData());
this.rejected = decodeInt(transaction.get(rlpIdx++).getRLPData()) == 1;
this.parsed = true;
}
Aggregations