@Override public Object[] callConstFunction(Block callBlock, String functionName, Object... args) { Transaction tx = CallTransaction.createCallTransaction( 0, 0, 100000000000000L, Hex.toHexString(getAddress()), 0, contract.getByName(functionName), args); tx.sign(new byte[32]); Repository repository = getBlockchain().getRepository().getSnapshotTo(callBlock.getStateRoot()).startTracking(); try { org.ethereum.core.TransactionExecutor executor = new org.ethereum.core.TransactionExecutor( tx, callBlock.getCoinbase(), repository, getBlockchain().getBlockStore(), getBlockchain().getProgramInvokeFactory(), callBlock) .setLocalCall(true); executor.init(); executor.execute(); executor.go(); executor.finalization(); return contract.getByName(functionName).decodeResult(executor.getResult().getHReturn()); } finally { repository.rollback(); } }
@Override public Object[] callFunction(long value, String functionName, Object... args) { byte[] data = contract.getByName(functionName).encode(args); submitNewTx(new PendingTx(null, BigInteger.valueOf(value), data, null, this)); return null; // TODO return either Future or pending state }