use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class KeystoreItem method parse.
public static KeystoreItem parse(byte[] bytes) throws UnsupportedEncodingException {
RLPList list = (RLPList) RLP.decode2(bytes).get(0);
KeystoreItem ki = new KeystoreItem();
ki.setId(new String(list.get(0).getRLPData(), "UTF-8"));
ki.setVersion(ByteUtil.byteArrayToInt(list.get(1).getRLPData()));
ki.setAddress(new String(list.get(2).getRLPData(), "US-ASCII"));
ki.setKeystoreCrypto(KeystoreCrypto.parse(list.get(3).getRLPData()));
return ki;
}
use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class AionBlock method createBlockFromNetwork.
public static AionBlock createBlockFromNetwork(A0BlockHeader header, byte[] body) {
if (header == null || body == null)
return null;
AionBlock block = new AionBlock();
block.header = header;
block.parsed = true;
RLPList items = (RLPList) RLP.decode2(body).get(0);
RLPList transactions = (RLPList) items.get(0);
if (!block.parseTxs(header.getTxTrieRoot(), transactions)) {
return null;
}
return block;
}
use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class AionBlock method parseRLP.
public void parseRLP() {
if (this.parsed) {
return;
}
synchronized (this) {
if (this.parsed)
return;
RLPList params = RLP.decode2(rlpEncoded);
RLPList block = (RLPList) params.get(0);
// Parse Header
RLPList header = (RLPList) block.get(0);
this.header = new A0BlockHeader(header);
// Parse Transactions
RLPList txTransactions = (RLPList) block.get(1);
this.parseTxs(this.header.getTxTrieRoot(), txTransactions);
this.parsed = true;
}
}
use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class AionBlockHeaderWrapper method parse.
protected void parse(byte[] bytes) {
List<RLPElement> params = RLP.decode2(bytes);
List<RLPElement> wrapper = (RLPList) params.get(0);
byte[] headerBytes = wrapper.get(0).getRLPData();
this.header = new A0BlockHeader(headerBytes);
this.nodeId = wrapper.get(1).getRLPData();
}
use of org.aion.rlp.RLPList in project aion by aionnetwork.
the class ResBlocksHeaders method decode.
public static ResBlocksHeaders decode(final byte[] _msgBytes) {
if (_msgBytes == null || _msgBytes.length == 0)
return null;
else {
try {
RLPList list = (RLPList) RLP.decode2(_msgBytes).get(0);
List<A0BlockHeader> blockHeaders = new ArrayList<>();
for (RLPElement aList : list) {
RLPList rlpData = ((RLPList) aList);
blockHeaders.add(A0BlockHeader.fromRLP(rlpData, true));
}
return new ResBlocksHeaders(blockHeaders);
} catch (Exception ex) {
return null;
}
}
}
Aggregations