Skip to content

Commit

Permalink
Merge pull request #147 from Ashuaidehao/master
Browse files Browse the repository at this point in the history
v1.5.1
  • Loading branch information
Ashuaidehao committed Jan 9, 2023
2 parents 3635530 + 9f65266 commit 1692a41
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 146 deletions.
2 changes: 1 addition & 1 deletion neo
Submodule neo updated 34 files
+1 −1 src/Directory.Build.props
+0 −12 src/Neo/Cryptography/Helper.cs
+2 −3 src/Neo/Neo.csproj
+4 −14 src/Neo/Plugins/Plugin.cs
+2 −0 src/Neo/SmartContract/ApplicationEngine.OpCodePrices.cs
+28 −0 src/Neo/SmartContract/ApplicationEngine.Runtime.cs
+38 −0 src/Neo/SmartContract/Native/ContractManagement.cs
+1 −1 src/Neo/SmartContract/Native/StdLib.cs
+1 −1 src/Neo/Wallets/IWalletFactory.cs
+2 −3 src/Neo/Wallets/NEP6/NEP6WalletFactory.cs
+0 −18 src/Neo/Wallets/SQLite/Account.cs
+0 −17 src/Neo/Wallets/SQLite/Address.cs
+0 −21 src/Neo/Wallets/SQLite/Contract.cs
+0 −18 src/Neo/Wallets/SQLite/Key.cs
+0 −35 src/Neo/Wallets/SQLite/SQLiteWalletFactory.cs
+0 −407 src/Neo/Wallets/SQLite/UserWallet.cs
+0 −29 src/Neo/Wallets/SQLite/UserWalletAccount.cs
+0 −59 src/Neo/Wallets/SQLite/VerificationContract.cs
+0 −64 src/Neo/Wallets/SQLite/WalletDataContext.cs
+2 −3 src/Neo/Wallets/Wallet.cs
+3 −3 tests/Directory.Build.props
+0 −9 tests/Neo.UnitTests/Cryptography/UT_Cryptography_Helper.cs
+2 −2 tests/Neo.UnitTests/Neo.UnitTests.csproj
+1 −1 tests/Neo.UnitTests/SmartContract/Native/UT_StdLib.cs
+4 −4 tests/Neo.UnitTests/VM/UT_Helper.cs
+3 −3 tests/Neo.UnitTests/Wallets/NEP6/UT_NEP6Wallet.cs
+0 −37 tests/Neo.UnitTests/Wallets/SQLite/UT_Account.cs
+0 −27 tests/Neo.UnitTests/Wallets/SQLite/UT_Address.cs
+0 −65 tests/Neo.UnitTests/Wallets/SQLite/UT_Contract.cs
+0 −37 tests/Neo.UnitTests/Wallets/SQLite/UT_Key.cs
+0 −174 tests/Neo.UnitTests/Wallets/SQLite/UT_UserWallet.cs
+0 −30 tests/Neo.UnitTests/Wallets/SQLite/UT_UserWalletAccount.cs
+0 −143 tests/Neo.UnitTests/Wallets/SQLite/UT_VerificationContract.cs
+1 −1 tests/Neo.UnitTests/Wallets/UT_Wallet.cs
4 changes: 2 additions & 2 deletions neo3-gui/neo3-gui/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new-gui",
"version": "1.5.0",
"version": "1.5.1",
"private": true,
"main": "main.js",
"homepage": "./",
Expand Down
12 changes: 9 additions & 3 deletions neo3-gui/neo3-gui/ClientApp/src/neonode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ class NeoNode {
}

start(env, errorCallback) {
this.node = this.runCommand("dotnet neo3-gui.dll", env, errorCallback);
if (isWin) {
this.node = this.runCommand("./neo3-gui.exe", env, errorCallback);

} else {
this.node = this.runCommand("./neo3-gui", env, errorCallback);
}
// this.node = this.runCommand("dotnet neo3-gui.dll", env, errorCallback);
}

startNode(network, port, errorCallback) {
Expand All @@ -40,7 +46,7 @@ class NeoNode {
* force restart node after 1 second (using config file)
*/
switchNode(network) {
console.log("switche to:", network);
console.log("switch to:", network);
if (network) {
Config.changeNetwork(network);
}
Expand Down Expand Up @@ -82,7 +88,7 @@ class NeoNode {
}

const ps = spawn(command, [], {
shell: true,
shell: false,
encoding: "utf8",
cwd: path.join(startPath, "build-neo-node"),
env: childEnv,
Expand Down
26 changes: 12 additions & 14 deletions neo3-gui/neo3-gui/Common/Analyzers/BlockAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Neo.SmartContract;
using Neo.SmartContract.Native;
using Neo.VM;
using Array = Neo.VM.Types.Array;

namespace Neo.Common.Analyzers
{
Expand Down Expand Up @@ -156,20 +155,19 @@ private void ProcessTransfer(NotifyEventArgs notification, Blockchain.Applicatio
Result.BalanceChangeAccounts.Add(new AccountAsset(transfer.To, transfer.Asset));
}

if (appExec.Trigger == TriggerType.Application)

var transferStorageItem = new TransferStorageItem()
{
var transferStorageItem = new TransferStorageItem()
{
From = transfer.From,
To = transfer.To,
Asset = transfer.Asset,
Amount = transfer.Amount,
TxId = appExec?.Transaction?.Hash,
Trigger = appExec.Trigger,
TokenId = transfer.TokenId?.ToHexString(),
};
Result.Transfers.Add(transferStorageItem);
}
From = transfer.From,
To = transfer.To,
Asset = transfer.Asset,
Amount = transfer.Amount,
TxId = appExec?.Transaction?.Hash,
Trigger = appExec.Trigger,
TokenId = transfer.TokenId?.ToHexString(),
};
Result.Transfers.Add(transferStorageItem);

}


Expand Down
20 changes: 3 additions & 17 deletions neo3-gui/neo3-gui/Common/Consoles/MainService.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
using Akka.Actor;
using Microsoft.Extensions.Configuration;
using Neo.IO;
using Neo.Ledger;
using Neo.Network.P2P;
using Neo.Network.P2P.Capabilities;
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using Neo.Plugins;
using Neo.Services;
using Neo.SmartContract;
using Neo.SmartContract.Manifest;
using Neo.SmartContract.Native;
using Neo.VM;
using Neo.Wallets;
using Neo.Wallets.NEP6;
using Neo.Wallets.SQLite;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -23,7 +16,6 @@
using System.Net;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -708,15 +700,9 @@ public void OpenWallet(string path, string password)
throw new FileNotFoundException();
}

if (Path.GetExtension(path) == ".db3")
{
CurrentWallet = UserWallet.Open(path, password, CliSettings.Default.Protocol);
}
else
{
NEP6Wallet nep6wallet = new NEP6Wallet(path, password, CliSettings.Default.Protocol);
CurrentWallet = nep6wallet;
}
NEP6Wallet nep6wallet = new NEP6Wallet(path, password, CliSettings.Default.Protocol);
CurrentWallet = nep6wallet;

}


Expand Down
128 changes: 76 additions & 52 deletions neo3-gui/neo3-gui/Common/Scanners/ExecuteResultScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,59 +86,89 @@ public async Task<bool> Sync(uint blockHeight)
return true;
}


var block = blockHeight.GetBlock();
var blockTime = block.Timestamp.FromTimestampMS();
if (blockHeight == 0)
{
SyncNativeContracts(blockTime);
}

if (block.Transactions.Length == 0)
bool hasTxs = block.Transactions.Length > 0;
if (hasTxs)
{
_db.AddSyncIndex(blockHeight);
return true;
SyncContracts(blockHeight, blockTime);
foreach (var transaction in block.Transactions)
{
_db.AddTransaction(new TransactionInfo()
{
TxId = transaction.Hash,
BlockHeight = blockHeight,
Sender = transaction.Sender,
Time = blockTime,
});
}
var transfers = new List<TransferInfo>();
var transferItems = _levelDb.GetTransfers(blockHeight);
if (transferItems.NotEmpty())
{
foreach (var item in transferItems.Where(t => t.TxId != null))
{
transfers.Add(new TransferInfo()
{
BlockHeight = blockHeight,
TimeStamp = block.Timestamp,
TxId = item.TxId,
From = item.From,
To = item.To,
Amount = item.Amount,
Asset = item.Asset,
Trigger = item.Trigger,
TokenId = item.TokenId
});
}
}
foreach (var transferInfo in transfers)
{
_db.AddTransfer(transferInfo);
}
}
SyncBalanceChanges(blockHeight);

SyncContracts(blockHeight, blockTime);
_db.AddSyncIndex(blockHeight);

foreach (var transaction in block.Transactions)
CommitAndReset(hasTxs);
if (hasTxs)
{
_db.AddTransaction(new TransactionInfo()
{
TxId = transaction.Hash,
BlockHeight = blockHeight,
Sender = transaction.Sender,
Time = blockTime,
});
Console.WriteLine($"Synced:{_scanHeight}[{block.Transactions.Length}]");
}
return true;
}


var transfers = new List<TransferInfo>();
var transferItems = _levelDb.GetTransfers(blockHeight);
if (transferItems.NotEmpty())
private void CommitAndReset(bool immediate)
{
var deadline = _db.LiveTime.TotalSeconds > 15;
if (immediate || deadline)
{
foreach (var item in transferItems)
{
transfers.Add(new TransferInfo()
{
BlockHeight = blockHeight,
TimeStamp = block.Timestamp,
TxId = item.TxId,
From = item.From,
To = item.To,
Amount = item.Amount,
Asset = item.Asset,
Trigger = item.Trigger,
TokenId = item.TokenId
});
}
_db.Commit();
}

foreach (var transferInfo in transfers)
if (deadline)
{
_db.AddTransfer(transferInfo);
//release memory
_db.Dispose();
_db = new TrackDB();
}
}


/// <summary>
/// Should run after <see cref="SyncContracts"/> method
/// update record will save after call <see cref="_db.Commit()"/> method;
/// new record will save immediately
/// </summary>
/// <param name="blockHeight"></param>
private void SyncBalanceChanges(uint blockHeight)
{
var balanceChanges = _levelDb.GetBalancingAccounts(blockHeight);
if (balanceChanges.NotEmpty())
{
Expand All @@ -148,25 +178,13 @@ public async Task<bool> Sync(uint blockHeight)
UpdateBalance(balanceChange.Account, balanceChange.Asset, snapshot);
}
}

_db.AddSyncIndex(blockHeight);
_db.Commit();

if (block.Transactions.Length > 0)
{
//Console.WriteLine($"Synced:{_scanHeight}[{block.Transactions.Length}] cost:[{_sw.ElapsedMilliseconds}]");
Console.WriteLine($"Synced:{_scanHeight}[{block.Transactions.Length}]");
}
if (_db.LiveTime.TotalSeconds > 15)
{
//release memory
_db.Dispose();
_db = new TrackDB();
}
return true;
}


/// <summary>
/// sync native contracts state into sqldb immediately
/// </summary>
/// <param name="blockTime"></param>
private void SyncNativeContracts(DateTime blockTime)
{
foreach (var nativeContract in NativeContract.Contracts)
Expand Down Expand Up @@ -194,7 +212,7 @@ private void SyncNativeContracts(DateTime blockTime)
}

/// <summary>
/// sync contract create\update\delete state
/// sync contract create\update\delete state into sqldb immediately
/// </summary>
/// <param name="blockHeight"></param>
/// <param name="blockTime"></param>
Expand Down Expand Up @@ -294,7 +312,13 @@ private Dictionary<UInt160, HashSet<string>> GetInvokeMethods(Transaction tx)
}



/// <summary>
/// update record will save after call <see cref="_db.Commit()"/> method;
/// new record will save immediately
/// </summary>
/// <param name="account"></param>
/// <param name="asset"></param>
/// <param name="snapshot"></param>
private void UpdateBalance(UInt160 account, UInt160 asset, DataCache snapshot)
{
try
Expand Down
Loading

0 comments on commit 1692a41

Please sign in to comment.