use of org.aion.rlp.RLPItem 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.RLPItem in project aion by aionnetwork.
the class AionContractDetailsImpl method decode.
@Override
public void decode(byte[] rlpCode) {
RLPList data = RLP.decode2(rlpCode);
RLPList rlpList = (RLPList) data.get(0);
RLPItem address = (RLPItem) rlpList.get(0);
RLPItem isExternalStorage = (RLPItem) rlpList.get(1);
RLPItem storage = (RLPItem) rlpList.get(2);
RLPElement code = rlpList.get(3);
RLPList keys = (RLPList) rlpList.get(4);
RLPItem storageRoot = (RLPItem) rlpList.get(5);
if (address.getRLPData() == null) {
this.address = Address.EMPTY_ADDRESS();
} else {
this.address = Address.wrap(address.getRLPData());
}
this.externalStorage = !Arrays.equals(isExternalStorage.getRLPData(), EMPTY_BYTE_ARRAY);
this.storageTrie.deserialize(storage.getRLPData());
if (code instanceof RLPList) {
for (RLPElement e : ((RLPList) code)) {
setCode(e.getRLPData());
}
} else {
setCode(code.getRLPData());
}
for (RLPElement key : keys) {
addKey(key.getRLPData());
}
if (externalStorage) {
storageTrie.withPruningEnabled(prune >= 0);
storageTrie.setRoot(storageRoot.getRLPData());
storageTrie.getCache().setDB(getExternalStorageDataSource());
}
externalStorage = (storage.getRLPData().length > detailsInMemoryStorageLimit) || externalStorage;
this.rlpEncoded = rlpCode;
}
Aggregations