From 98a33fefc6a56f855df652c987d73a745b1c27d0 Mon Sep 17 00:00:00 2001 From: Shuai Date: Sun, 8 Aug 2021 17:13:04 +0800 Subject: [PATCH] fix assets --- .../ClientApp/src/components/Chain/assetdetail.js | 2 +- .../neo3-gui/Common/Scanners/ExecuteResultScanner.cs | 12 ++++++++++++ neo3-gui/neo3-gui/Common/Storage/TrackDB.cs | 5 +++++ neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs | 5 +++++ neo3-gui/neo3-gui/Models/JStackItem.cs | 2 +- .../neo3-gui/Services/ApiServices/BlockApiService.cs | 2 +- .../Services/ApiServices/TransactionApiService.cs | 3 ++- 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/neo3-gui/neo3-gui/ClientApp/src/components/Chain/assetdetail.js b/neo3-gui/neo3-gui/ClientApp/src/components/Chain/assetdetail.js index af7411dd..d4dee51b 100644 --- a/neo3-gui/neo3-gui/ClientApp/src/components/Chain/assetdetail.js +++ b/neo3-gui/neo3-gui/ClientApp/src/components/Chain/assetdetail.js @@ -112,7 +112,7 @@ class Assetdetail extends React.Component { {t("blockchain.precision")}: - {assetdetail.decimals ? assetdetail.decimals : "--"} + {assetdetail.decimals ? assetdetail.decimals : "0"}
  • diff --git a/neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs b/neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs index 6a37dd00..cbaed042 100644 --- a/neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs +++ b/neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs @@ -25,16 +25,28 @@ public class ExecuteResultScanner private bool _running = true; private uint _scanHeight = 0; + private uint _lastHeight = 0; + private DateTime _lastTime; + public async Task Start() { _running = true; _scanHeight = _db.GetMaxSyncIndex() ?? 0; + _lastHeight = _scanHeight; + _lastTime = DateTime.Now; while (_running) { try { if (await Sync(_scanHeight)) { + if (_scanHeight - _lastHeight >= 500) + { + var span = DateTime.Now - _lastTime; + Console.WriteLine($"Sync[{_lastHeight}-{_scanHeight}],cost:{span.TotalSeconds}"); + _lastTime=DateTime.Now; + _lastHeight = _scanHeight; + } _scanHeight++; } if (_scanHeight > this.GetCurrentHeight()) diff --git a/neo3-gui/neo3-gui/Common/Storage/TrackDB.cs b/neo3-gui/neo3-gui/Common/Storage/TrackDB.cs index c5907e2c..5393bdd0 100644 --- a/neo3-gui/neo3-gui/Common/Storage/TrackDB.cs +++ b/neo3-gui/neo3-gui/Common/Storage/TrackDB.cs @@ -255,6 +255,11 @@ public PageList QueryTransactions(TransactionFilter filter, boo var contracts = filter.Contracts.Select(a => a.ToBigEndianHex()).Distinct().ToList(); query = query.Where(tx => tx.InvokeContracts.Any(c => contracts.Contains(c.Contract.Hash) && c.Contract.DeleteTxId == null)); } + if (filter.Assets.NotEmpty()) + { + var assets = filter.Assets.Select(a => a.ToBigEndianHex()).Distinct().ToList(); + query = query.Where(tx => tx.Transfers.Any(c => assets.Contains(c.Asset.Hash) && c.Asset.DeleteTxId == null)); + } var pageList = new PageList(); var pageIndex = filter.PageIndex <= 0 ? 0 : filter.PageIndex - 1; pageList.TotalCount = query.Count(); diff --git a/neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs b/neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs index 7f3a6358..5727131b 100644 --- a/neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs +++ b/neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs @@ -40,6 +40,11 @@ public class TransactionFilter /// public List Contracts { get; set; } + /// + /// Relate asset contracts hash + /// + public List Assets { get; set; } + /// /// start from 1,paged result only if this is not null /// diff --git a/neo3-gui/neo3-gui/Models/JStackItem.cs b/neo3-gui/neo3-gui/Models/JStackItem.cs index f5ff1102..8770b6cb 100644 --- a/neo3-gui/neo3-gui/Models/JStackItem.cs +++ b/neo3-gui/neo3-gui/Models/JStackItem.cs @@ -33,7 +33,7 @@ public static JStackItem FromJson(JObject json) TypeCode = json["type"].TryGetEnum(), Type = json["type"].AsString(), }; - if (parameter.Type == "ByteString") + if (parameter.Type == "ByteString" || parameter.Type == "Buffer") { parameter.TypeCode = ContractParameterType.ByteArray; } diff --git a/neo3-gui/neo3-gui/Services/ApiServices/BlockApiService.cs b/neo3-gui/neo3-gui/Services/ApiServices/BlockApiService.cs index 3f0f5e3e..a2b92301 100644 --- a/neo3-gui/neo3-gui/Services/ApiServices/BlockApiService.cs +++ b/neo3-gui/neo3-gui/Services/ApiServices/BlockApiService.cs @@ -116,7 +116,7 @@ public async Task GetAsset(UInt160 asset) using var db = new TrackDB(); var record = db.GetContract(asset); var trans = db.QueryTransactions(new TransactionFilter() - { Contracts = new List() { asset }, PageSize = 0 }); + { Assets = new List() { asset }, PageSize = 0 }); return new AssetInfoModel() { Asset = assetInfo.Asset, diff --git a/neo3-gui/neo3-gui/Services/ApiServices/TransactionApiService.cs b/neo3-gui/neo3-gui/Services/ApiServices/TransactionApiService.cs index 561ffb7d..bfc9605e 100644 --- a/neo3-gui/neo3-gui/Services/ApiServices/TransactionApiService.cs +++ b/neo3-gui/neo3-gui/Services/ApiServices/TransactionApiService.cs @@ -197,8 +197,9 @@ public async Task QueryNep5Transactions(int pageIndex = 1, int limit = 1 } if (asset != null) { - filter.Contracts = new List() { asset }; + filter.Assets = new List() { asset }; } + var trans = db.QueryTransactions(filter, true); var result = new PageList {