Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preview, submit tx and tx stream APIs in Rust #95

Merged
merged 11 commits into from
Aug 30, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public final class CoreApiServer {

/**
* Stores a pointer to the rust core api server across JNI calls. In the JNI model, this is
* equivalent to the CoreApiServer "owning" the rust core api server memory. On each call into Rust,
* we map the rustCoreApiServerPointer onto a concrete implementation in Rust land, and it uses
* that to access all state and make calls.
* equivalent to the CoreApiServer "owning" the rust core api server memory. On each call into
* Rust, we map the rustCoreApiServerPointer onto a concrete implementation in Rust land, and it
* uses that to access all state and make calls.
*/
@SuppressWarnings("unused")
private final long rustCoreApiServerPointer = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ public static NetworkDefinition from(Network network) {

public static NetworkDefinition LOCAL_SIMULATOR = NetworkDefinition.from(Network.LOCALSIMULATOR);
public static NetworkDefinition INT_TEST_NET = NetworkDefinition.from(Network.INTEGRATIONTESTNET);
public static NetworkDefinition LOCALNET = NetworkDefinition.from(Network.LOCALNET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
import com.radixdlt.sbor.codec.CodecMap;
import com.radixdlt.sbor.codec.StructCodec;
import com.radixdlt.statecomputer.commit.CommitRequest;
import com.radixdlt.statecomputer.preview.FeeSummary;
import com.radixdlt.statecomputer.preview.PreviewError;
import com.radixdlt.statecomputer.preview.PreviewFlags;
import com.radixdlt.statecomputer.preview.PreviewRequest;
import com.radixdlt.statecomputer.preview.PreviewResult;
import com.radixdlt.statemanager.CoreApiServerConfig;
import com.radixdlt.statemanager.StateManagerConfig;
import com.radixdlt.transaction.ExecutedTransactionReceipt;
Expand Down Expand Up @@ -123,17 +118,12 @@ public static void registerCodecsWithCodecMap(CodecMap codecMap) {
NetworkDefinition.registerCodec(codecMap);
StateManagerConfig.registerCodec(codecMap);
RawTransaction.registerCodec(codecMap);
PreviewFlags.registerCodec(codecMap);
PreviewRequest.registerCodec(codecMap);
PreviewResult.registerCodec(codecMap);
PreviewError.registerCodec(codecMap);
TransactionStatus.registerCodec(codecMap);
Decimal.registerCodec(codecMap);
LogLevel.registerCodec(codecMap);
ComponentAddress.registerCodec(codecMap);
PackageAddress.registerCodec(codecMap);
ResourceAddress.registerCodec(codecMap);
FeeSummary.registerCodec(codecMap);
TID.registerCodec(codecMap);
StateManagerRuntimeError.registerCodec(codecMap);
MempoolError.registerCodec(codecMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
import com.radixdlt.rev2.Decimal;
import com.radixdlt.sbor.NativeCalls;
import com.radixdlt.statecomputer.commit.CommitRequest;
import com.radixdlt.statecomputer.preview.PreviewError;
import com.radixdlt.statecomputer.preview.PreviewRequest;
import com.radixdlt.statecomputer.preview.PreviewResult;
import com.radixdlt.statemanager.StateManager;
import com.radixdlt.transaction.REv2TransactionAndProofStore;
import com.radixdlt.transactions.RawTransaction;
Expand All @@ -93,9 +90,6 @@ public RustStateComputer(StateManager stateManager) {
verifyFunc =
NativeCalls.Func1.with(
stateManager, new TypeToken<>() {}, new TypeToken<>() {}, RustStateComputer::verify);
previewFunc =
NativeCalls.Func1.with(
stateManager, new TypeToken<>() {}, new TypeToken<>() {}, RustStateComputer::preview);
commitFunc =
NativeCalls.Func1.with(
stateManager, new TypeToken<>() {}, new TypeToken<>() {}, RustStateComputer::commit);
Expand Down Expand Up @@ -136,19 +130,10 @@ public Result<Unit, String> verify(RawTransaction transaction) {
return verifyFunc.call(transaction);
}

public Result<PreviewResult, PreviewError> preview(PreviewRequest previewRequest) {
return previewFunc.call(previewRequest);
}

private final NativeCalls.Func1<StateManager, RawTransaction, Result<Unit, String>> verifyFunc;

private static native byte[] verify(StateManager stateManager, byte[] payload);

private final NativeCalls.Func1<StateManager, PreviewRequest, Result<PreviewResult, PreviewError>>
previewFunc;

private static native byte[] preview(StateManager stateManager, byte[] payload);

private final NativeCalls.Func1<StateManager, CommitRequest, Unit> commitFunc;

private static native byte[] commit(StateManager stateManager, byte[] payload);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading