Skip to content

Commit

Permalink
fix assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashuaidehao committed Aug 8, 2021
1 parent 98c2790 commit 98a33fe
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Assetdetail extends React.Component {
<span className="hint">
{t("blockchain.precision")}
</span>
{assetdetail.decimals ? assetdetail.decimals : "--"}
{assetdetail.decimals ? assetdetail.decimals : "0"}
</li>
<li>
<span className="hint">
Expand Down
12 changes: 12 additions & 0 deletions neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
5 changes: 5 additions & 0 deletions neo3-gui/neo3-gui/Common/Storage/TrackDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ public PageList<TransactionInfo> 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<TransactionInfo>();
var pageIndex = filter.PageIndex <= 0 ? 0 : filter.PageIndex - 1;
pageList.TotalCount = query.Count();
Expand Down
5 changes: 5 additions & 0 deletions neo3-gui/neo3-gui/Common/Storage/TransferFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class TransactionFilter
/// </summary>
public List<UInt160> Contracts { get; set; }

/// <summary>
/// Relate asset contracts hash
/// </summary>
public List<UInt160> Assets { get; set; }

/// <summary>
/// start from 1,paged result only if this is not null
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Models/JStackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static JStackItem FromJson(JObject json)
TypeCode = json["type"].TryGetEnum<ContractParameterType>(),
Type = json["type"].AsString(),
};
if (parameter.Type == "ByteString")
if (parameter.Type == "ByteString" || parameter.Type == "Buffer")
{
parameter.TypeCode = ContractParameterType.ByteArray;
}
Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Services/ApiServices/BlockApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task<object> GetAsset(UInt160 asset)
using var db = new TrackDB();
var record = db.GetContract(asset);
var trans = db.QueryTransactions(new TransactionFilter()
{ Contracts = new List<UInt160>() { asset }, PageSize = 0 });
{ Assets = new List<UInt160>() { asset }, PageSize = 0 });
return new AssetInfoModel()
{
Asset = assetInfo.Asset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ public async Task<object> QueryNep5Transactions(int pageIndex = 1, int limit = 1
}
if (asset != null)
{
filter.Contracts = new List<UInt160>() { asset };
filter.Assets = new List<UInt160>() { asset };
}

var trans = db.QueryTransactions(filter, true);
var result = new PageList<TransactionPreviewModel>
{
Expand Down

0 comments on commit 98a33fe

Please sign in to comment.