Search in sources :

Example 1 with RLPElement

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

Example 2 with RLPElement

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

Example 3 with RLPElement

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());
    }
}
Also used : TrieImpl(org.aion.mcf.trie.TrieImpl) RLPElement(org.aion.rlp.RLPElement) AionTransaction(org.aion.zero.types.AionTransaction)

Example 4 with RLPElement

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

Example 5 with RLPElement

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;
}
Also used : TxTouchedStorage(org.aion.mcf.core.TxTouchedStorage) RLPElement(org.aion.rlp.RLPElement) DataWord(org.aion.mcf.vm.types.DataWord) RLPList(org.aion.rlp.RLPList)

Aggregations

RLPElement (org.aion.rlp.RLPElement)39 SharedRLPList (org.aion.rlp.SharedRLPList)23 RLPList (org.aion.rlp.RLPList)18 AionAddress (org.aion.types.AionAddress)11 RLPContractDetails (org.aion.zero.impl.db.DetailsDataStore.RLPContractDetails)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 ByteArrayWrapper (org.aion.util.types.ByteArrayWrapper)7 HashMap (java.util.HashMap)6 RLPItem (org.aion.rlp.RLPItem)6 SecureTrie (org.aion.zero.impl.trie.SecureTrie)6 SharedRLPItem (org.aion.rlp.SharedRLPItem)5 ByteArrayKeyValueDatabase (org.aion.db.impl.ByteArrayKeyValueDatabase)4 MockDB (org.aion.db.impl.mockdb.MockDB)4 BigInteger (java.math.BigInteger)3 Logger (org.slf4j.Logger)3 DataWord (org.aion.mcf.vm.types.DataWord)2 Log (org.aion.types.Log)2 Block (org.aion.zero.impl.types.Block)2 A0BlockHeader (org.aion.zero.types.A0BlockHeader)2