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

Dispose ApplicationEngine after using #1336

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/neo/Network/RPC/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void Dispose()

private JObject GetInvokeResult(byte[] script, IVerifiable checkWitnessHashes = null)
{
ApplicationEngine engine = ApplicationEngine.Run(script, checkWitnessHashes, extraGAS: MaxGasInvoke);
using ApplicationEngine engine = ApplicationEngine.Run(script, checkWitnessHashes, extraGAS: MaxGasInvoke);
JObject json = new JObject();
json["script"] = script.ToHexString();
json["state"] = engine.State;
Expand Down
2 changes: 1 addition & 1 deletion src/neo/Wallets/AssetDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AssetDescriptor(UInt160 asset_id)
sb.EmitAppCall(asset_id, "name");
script = sb.ToArray();
}
ApplicationEngine engine = ApplicationEngine.Run(script, extraGAS: 3_000_000);
using ApplicationEngine engine = ApplicationEngine.Run(script, extraGAS: 3_000_000);
if (engine.State.HasFlag(VMState.FAULT)) throw new ArgumentException();
this.AssetId = asset_id;
this.AssetName = engine.ResultStack.Pop().GetString();
Expand Down
2 changes: 1 addition & 1 deletion src/neo/Wallets/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public BigDecimal GetBalance(UInt160 asset_id, params UInt160[] accounts)
sb.EmitAppCall(asset_id, "decimals");
script = sb.ToArray();
}
ApplicationEngine engine = ApplicationEngine.Run(script, extraGAS: 20000000L * accounts.Length);
using ApplicationEngine engine = ApplicationEngine.Run(script, extraGAS: 20000000L * accounts.Length);
if (engine.State.HasFlag(VMState.FAULT))
return new BigDecimal(0, 0);
byte decimals = (byte)engine.ResultStack.Pop().GetBigInteger();
Expand Down