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

[Neo Core] fix obsolete warning #3428

Merged
merged 1 commit into from
Jul 22, 2024
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.CLI/CLI/MainService.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/OracleService/OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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());
}

Expand Down
26 changes: 13 additions & 13 deletions tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand All @@ -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);
Expand All @@ -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());
Expand All @@ -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();
Expand All @@ -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());

Expand All @@ -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();
Expand All @@ -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());
Expand Down
Loading