From 219c388064510abf7011917afc2ded4d0e9322df Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Wed, 25 Mar 2020 16:35:20 +0800 Subject: [PATCH 1/2] deal with contract destory --- src/RpcNep5Tracker/RpcNep5Tracker.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/RpcNep5Tracker/RpcNep5Tracker.cs b/src/RpcNep5Tracker/RpcNep5Tracker.cs index d94ab0d60..e01e26462 100644 --- a/src/RpcNep5Tracker/RpcNep5Tracker.cs +++ b/src/RpcNep5Tracker/RpcNep5Tracker.cs @@ -286,6 +286,11 @@ public JObject GetNep5Balances(JArray _params) foreach (var (key, value) in dbCache.Find(prefix)) { JObject balance = new JObject(); + if (Blockchain.Singleton.View.Contracts.TryGet(key.AssetScriptHash) is null) + { + dbCache.Delete(key); + continue; + } balance["asset_hash"] = key.AssetScriptHash.ToString(); balance["amount"] = value.Balance.ToString(); balance["last_updated_block"] = value.LastUpdatedBlock; From 5867258c312b3602a2a0871d4c063669612e71e5 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Wed, 25 Mar 2020 17:29:10 +0800 Subject: [PATCH 2/2] remove delete key --- src/RpcNep5Tracker/RpcNep5Tracker.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/RpcNep5Tracker/RpcNep5Tracker.cs b/src/RpcNep5Tracker/RpcNep5Tracker.cs index e01e26462..62a68cb34 100644 --- a/src/RpcNep5Tracker/RpcNep5Tracker.cs +++ b/src/RpcNep5Tracker/RpcNep5Tracker.cs @@ -287,10 +287,7 @@ public JObject GetNep5Balances(JArray _params) { JObject balance = new JObject(); if (Blockchain.Singleton.View.Contracts.TryGet(key.AssetScriptHash) is null) - { - dbCache.Delete(key); continue; - } balance["asset_hash"] = key.AssetScriptHash.ToString(); balance["amount"] = value.Balance.ToString(); balance["last_updated_block"] = value.LastUpdatedBlock;