diff --git a/src/Neo.CLI/CLI/MainService.Blockchain.cs b/src/Neo.CLI/CLI/MainService.Blockchain.cs index 090939de49..2ac9c46ea4 100644 --- a/src/Neo.CLI/CLI/MainService.Blockchain.cs +++ b/src/Neo.CLI/CLI/MainService.Blockchain.cs @@ -82,7 +82,7 @@ private void OnShowBlockCommand(string indexOrHash) ConsoleHelper.Info("", " PrevHash: ", $"{block.PrevHash}"); ConsoleHelper.Info("", " NextConsensus: ", $"{block.NextConsensus}"); ConsoleHelper.Info("", " PrimaryIndex: ", $"{block.PrimaryIndex}"); - ConsoleHelper.Info("", " PrimaryPubKey: ", $"{NativeContract.NEO.GetCommittee(NeoSystem.GetSnapshot())[block.PrimaryIndex]}"); + ConsoleHelper.Info("", " PrimaryPubKey: ", $"{NativeContract.NEO.GetCommittee(NeoSystem.GetSnapshotCache())[block.PrimaryIndex]}"); ConsoleHelper.Info("", " Version: ", $"{block.Version}"); ConsoleHelper.Info("", " Size: ", $"{block.Size} Byte(s)"); ConsoleHelper.Info(); diff --git a/src/Plugins/OracleService/OracleService.cs b/src/Plugins/OracleService/OracleService.cs index d7a54c5c9d..3f14c8eab8 100644 --- a/src/Plugins/OracleService/OracleService.cs +++ b/src/Plugins/OracleService/OracleService.cs @@ -234,7 +234,7 @@ public JObject SubmitOracleResponse(JArray _params) finishedCache.ContainsKey(requestId).False_Or(RpcError.OracleRequestFinished); - using (var snapshot = _system.GetSnapshot()) + using (var snapshot = _system.GetSnapshotCache()) { uint height = NativeContract.Ledger.CurrentIndex(snapshot) + 1; var oracles = NativeContract.RoleManagement.GetDesignatedByRole(snapshot, Role.Oracle, height); @@ -326,7 +326,7 @@ private async void ProcessRequestsAsync() { while (!cancelSource.IsCancellationRequested) { - using (var snapshot = _system.GetSnapshot()) + using (var snapshot = _system.GetSnapshotCache()) { SyncPendingQueue(snapshot); foreach (var (id, request) in NativeContract.Oracle.GetRequests(snapshot)) diff --git a/src/Plugins/RpcServer/RpcServer.Wallet.cs b/src/Plugins/RpcServer/RpcServer.Wallet.cs index ab5724e588..155c56d91b 100644 --- a/src/Plugins/RpcServer/RpcServer.Wallet.cs +++ b/src/Plugins/RpcServer/RpcServer.Wallet.cs @@ -97,7 +97,7 @@ protected virtual JToken GetWalletUnclaimedGas(JArray _params) CheckWallet(); // Datoshi is the smallest unit of GAS, 1 GAS = 10^8 Datoshi BigInteger datoshi = BigInteger.Zero; - using (var snapshot = system.GetSnapshot()) + using (var snapshot = system.GetSnapshotCache()) { uint height = NativeContract.Ledger.CurrentIndex(snapshot) + 1; foreach (UInt160 account in wallet.GetAccounts().Select(p => p.ScriptHash)) diff --git a/src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs b/src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs index 12d3c208bc..a799e79a7a 100644 --- a/src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs +++ b/src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs @@ -283,7 +283,7 @@ public JToken GetNep11Properties(JArray _params) using ScriptBuilder sb = new(); sb.EmitDynamicCall(nep11Hash, "properties", CallFlags.ReadOnly, tokenId); - using var snapshot = _neoSystem.GetSnapshot(); + using var snapshot = _neoSystem.GetSnapshotCache(); using var engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings); JObject json = new(); diff --git a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs index c9007f6580..ab5693937f 100644 --- a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs +++ b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs @@ -239,7 +239,7 @@ public void TestGetCandidates() var json = new JArray(); var validators = NativeContract.NEO.GetNextBlockValidators(snapshot, _neoSystem.Settings.ValidatorsCount); snapshot.Commit(); - var candidates = NativeContract.NEO.GetCandidates(_neoSystem.GetSnapshot()); + var candidates = NativeContract.NEO.GetCandidates(_neoSystem.GetSnapshotCache()); foreach (var candidate in candidates) { @@ -266,7 +266,7 @@ public void TestGetCommittee() public void TestGetNativeContracts() { var result = _rpcServer.GetNativeContracts(new JArray()); - var contracts = new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(_neoSystem.GetSnapshot(), p.Hash).ToJson())); + var contracts = new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(_neoSystem.GetSnapshotCache(), p.Hash).ToJson())); Assert.AreEqual(contracts.ToString(), result.ToString()); } diff --git a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs index b75706e001..413df59441 100644 --- a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs +++ b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs @@ -49,7 +49,7 @@ public void TestGetVersion() [TestMethod] public void TestSendRawTransaction_Normal() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount); var txString = Convert.ToBase64String(tx.ToArray()); @@ -69,7 +69,7 @@ public void TestSendRawTransaction_InvalidTransactionFormat() [TestMethod] public void TestSendRawTransaction_InsufficientBalance() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InsufficientBalance); var txString = Convert.ToBase64String(tx.ToArray()); @@ -82,7 +82,7 @@ public void TestSendRawTransaction_InsufficientBalance() [TestMethod] public void TestSendRawTransaction_InvalidSignature() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidSignature); var txString = Convert.ToBase64String(tx.ToArray()); @@ -95,7 +95,7 @@ public void TestSendRawTransaction_InvalidSignature() [TestMethod] public void TestSendRawTransaction_InvalidScript() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidScript); var txString = Convert.ToBase64String(tx.ToArray()); @@ -108,7 +108,7 @@ public void TestSendRawTransaction_InvalidScript() [TestMethod] public void TestSendRawTransaction_InvalidAttribute() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.InvalidAttribute); var txString = Convert.ToBase64String(tx.ToArray()); @@ -123,7 +123,7 @@ public void TestSendRawTransaction_InvalidAttribute() [TestMethod] public void TestSendRawTransaction_Oversized() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.Oversized); var txString = Convert.ToBase64String(tx.ToArray()); @@ -137,7 +137,7 @@ public void TestSendRawTransaction_Oversized() [TestMethod] public void TestSendRawTransaction_Expired() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateInvalidTransaction(snapshot, _wallet, _walletAccount, TestUtils.InvalidTransactionType.Expired); var txString = Convert.ToBase64String(tx.ToArray()); @@ -150,7 +150,7 @@ public void TestSendRawTransaction_Expired() [TestMethod] public void TestSendRawTransaction_PolicyFailed() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount); var txString = Convert.ToBase64String(tx.ToArray()); NativeContract.Policy.BlockAccount(snapshot, _walletAccount.ScriptHash); @@ -165,7 +165,7 @@ public void TestSendRawTransaction_PolicyFailed() [TestMethod] public void TestSendRawTransaction_AlreadyInPool() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount); _neoSystem.MemPool.TryAdd(tx, snapshot); var txString = Convert.ToBase64String(tx.ToArray()); @@ -179,7 +179,7 @@ public void TestSendRawTransaction_AlreadyInPool() [TestMethod] public void TestSendRawTransaction_AlreadyInBlockchain() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var tx = TestUtils.CreateValidTx(snapshot, _wallet, _walletAccount); TestUtils.AddTransactionToBlockchain(snapshot, tx); snapshot.Commit(); @@ -195,7 +195,7 @@ public void TestSendRawTransaction_AlreadyInBlockchain() [TestMethod] public void TestSubmitBlock_Normal() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1); var blockString = Convert.ToBase64String(block.ToArray()); @@ -220,7 +220,7 @@ public void TestSubmitBlock_InvalidBlockFormat() [TestMethod] public void TestSubmitBlock_AlreadyExists() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1); TestUtils.BlocksAdd(snapshot, block.Hash, block); snapshot.Commit(); @@ -235,7 +235,7 @@ public void TestSubmitBlock_AlreadyExists() [TestMethod] public void TestSubmitBlock_InvalidBlock() { - var snapshot = _neoSystem.GetSnapshot(); + var snapshot = _neoSystem.GetSnapshotCache(); var block = TestUtils.CreateBlockWithValidTransactions(snapshot, _wallet, _walletAccount, 1); block.Header.Witness = new Witness(); var blockString = Convert.ToBase64String(block.ToArray());