Search in sources :

Example 16 with RLPList

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

Example 17 with RLPList

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

Example 18 with RLPList

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

Example 19 with RLPList

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

Example 20 with RLPList

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