Search in sources :

Example 1 with RLPList

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());
    }
}
Also used : RLPItem(org.aion.rlp.RLPItem) Value(org.aion.rlp.Value) RLPList(org.aion.rlp.RLPList)

Example 2 with RLPList

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;
}
Also used : RLPList(org.aion.rlp.RLPList)

Example 3 with RLPList

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);
}
Also used : RLPElement(org.aion.rlp.RLPElement) ArrayList(java.util.ArrayList) RLPList(org.aion.rlp.RLPList)

Example 4 with RLPList

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();
}
Also used : RLPElement(org.aion.rlp.RLPElement) BigInteger(java.math.BigInteger) RLPList(org.aion.rlp.RLPList)

Example 5 with RLPList

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;
}
Also used : ByteUtil.toHexString(org.aion.base.util.ByteUtil.toHexString) RLPList(org.aion.rlp.RLPList)

Aggregations

RLPList (org.aion.rlp.RLPList)30 RLPElement (org.aion.rlp.RLPElement)18 RLPItem (org.aion.rlp.RLPItem)7 SharedRLPList (org.aion.rlp.SharedRLPList)7 SharedRLPItem (org.aion.rlp.SharedRLPItem)5 AionAddress (org.aion.types.AionAddress)5 RLPContractDetails (org.aion.zero.impl.db.DetailsDataStore.RLPContractDetails)5 Test (org.junit.Test)5 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)3 A0BlockHeader (org.aion.zero.types.A0BlockHeader)3 HashMap (java.util.HashMap)2 DataWord (org.aion.mcf.vm.types.DataWord)2 ByteArrayWrapper (org.aion.util.types.ByteArrayWrapper)2 DatabaseType (org.aion.zero.impl.sync.DatabaseType)2 SecureTrie (org.aion.zero.impl.trie.SecureTrie)2 ByteUtil.toHexString (org.aion.base.util.ByteUtil.toHexString)1 ISignature (org.aion.crypto.ISignature)1 TxTouchedStorage (org.aion.mcf.core.TxTouchedStorage)1 Value (org.aion.rlp.Value)1