use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RemascStorageProvider method getBrokenSelectionRule.
public Boolean getBrokenSelectionRule() {
if (brokenSelectionRule != null) {
return brokenSelectionRule;
}
DataWord address = new DataWord(BROKEN_SELECTION_RULE_KEY.getBytes(StandardCharsets.UTF_8));
byte[] bytes = this.repository.getStorageBytes(this.contractAddress, address);
if (bytes == null || bytes.length == 0) {
return Boolean.FALSE;
}
if (bytes[0] == 0) {
return Boolean.FALSE;
} else {
return Boolean.TRUE;
}
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class ContractDetailsCacheImpl method get.
@Override
public DataWord get(DataWord key) {
DataWord value = storage.get(key);
if (value != null) {
value = value.clone();
} else {
if (origContract == null) {
return null;
}
value = origContract.get(key);
storage.put(key.clone(), value == null ? DataWord.ZERO.clone() : value.clone());
}
if (value == null || value.isZero()) {
return null;
} else {
return value;
}
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class ContractDetailsCacheImpl method setStorage.
@Override
public void setStorage(List<DataWord> storageKeys, List<DataWord> storageValues) {
for (int i = 0; i < storageKeys.size(); ++i) {
DataWord key = storageKeys.get(i);
DataWord value = storageValues.get(i);
if (value.isZero()) {
storage.put(key, null);
}
}
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class Stack method swap.
public void swap(int from, int to) {
if (isAccessible(from) && isAccessible(to) && (from != to)) {
if (traceListener != null) {
traceListener.onStackSwap(from, to);
}
DataWord tmp = get(from);
set(from, set(to, tmp));
}
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class ProgramInvokeImpl method getDataValue.
/* CALLDATALOAD op */
public DataWord getDataValue(DataWord indexData) {
BigInteger tempIndex = indexData.value();
// possible overflow is caught below
int index = tempIndex.intValue();
// maximum datavalue size
int size = 32;
if (msgData == null || index >= msgData.length || tempIndex.compareTo(maxMsgData) == 1) {
return new DataWord();
}
if (index + size > msgData.length) {
size = msgData.length - index;
}
byte[] data = new byte[32];
System.arraycopy(msgData, index, data, 0, size);
return new DataWord(data);
}
Aggregations