use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryBlockStore method getChainHead.
@Override
public StoredBlock getChainHead() throws BlockStoreException {
byte[] ba = repository.getStorageBytes(contractAddress, new DataWord(BLOCK_STORE_CHAIN_HEAD_KEY.getBytes(StandardCharsets.UTF_8)));
if (ba == null) {
return null;
}
StoredBlock storedBlock = byteArrayToStoredBlock(ba);
return storedBlock;
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryBlockStore method get.
@Override
public synchronized StoredBlock get(Sha256Hash hash) throws BlockStoreException {
byte[] ba = repository.getStorageBytes(contractAddress, new DataWord(hash.toString()));
if (ba == null) {
return null;
}
StoredBlock storedBlock = byteArrayToStoredBlock(ba);
return storedBlock;
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class SamplePrecompiledContract method IncrementResult.
public void IncrementResult(Object... args) {
DataWord keyWord = new DataWord("result".getBytes(StandardCharsets.UTF_8));
DataWord storedValue = repository.getStorageValue(contractAddress, keyWord);
int result = (storedValue != null ? storedValue.intValue() : 0) + 1;
DataWord valWord = new DataWord(result);
repository.addStorageRow(contractAddress, keyWord, valWord);
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class SamplePrecompiledContract method Method1.
public int Method1(Object... args) {
RskAddress addr = new RskAddress("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
Coin balance = Coin.valueOf(50000);
repository.addBalance(addr, balance);
DataWord keyWord = new DataWord("result".getBytes(StandardCharsets.UTF_8));
DataWord storedValue = repository.getStorageValue(contractAddress, keyWord);
int result = (storedValue != null ? storedValue.intValue() : 0) + 1;
DataWord valWord = new DataWord(result);
repository.addStorageRow(contractAddress, keyWord, valWord);
logs.add(new LogInfo(contractAddress.getBytes(), null, null));
return result;
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class BridgeEventLoggerImpl method logCommitFederation.
public void logCommitFederation(Block executionBlock, Federation oldFederation, Federation newFederation) {
List<DataWord> topics = Collections.singletonList(Bridge.COMMIT_FEDERATION_TOPIC);
byte[] oldFedFlatPubKeys = flatKeysAsRlpCollection(oldFederation.getPublicKeys());
byte[] oldFedData = RLP.encodeList(RLP.encodeElement(oldFederation.getAddress().getHash160()), RLP.encodeList(oldFedFlatPubKeys));
byte[] newFedFlatPubKeys = flatKeysAsRlpCollection(newFederation.getPublicKeys());
byte[] newFedData = RLP.encodeList(RLP.encodeElement(newFederation.getAddress().getHash160()), RLP.encodeList(newFedFlatPubKeys));
long newFedActivationBlockNumber = executionBlock.getNumber() + this.bridgeConstants.getFederationActivationAge();
byte[] data = RLP.encodeList(oldFedData, newFedData, RLP.encodeString(Long.toString(newFedActivationBlockNumber)));
this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, topics, data));
}
Aggregations