Skip to content

Commit

Permalink
sc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashuaidehao committed Jan 9, 2023
1 parent 5aa2afd commit 0c86dac
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 3 deletions.
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
146 changes: 146 additions & 0 deletions neo3-gui/neo3-gui/Common/Storage/SQLiteModules/IRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Neo;
using Neo.Common.Storage;
using Neo.Common.Storage.SQLiteModules;
using Neo.Models;

interface IRepository
{
byte[] Identity { get; }
uint? GetMaxSyncIndex();
void AddSyncIndex(uint index);
//void SetMaxSyncIndex(uint height);

void AddTransfer(TransferInfo transfer);
void AddTransaction(TransactionInfo transaction);


void UpdateBalance(UInt160 addressHash, UInt160 assetHash, BigInteger balance, uint height);

PageList<TransactionInfo> QueryTransactions(TransactionFilter filter, bool includeTransfers = false);
IEnumerable<BalanceInfo> FindAssetBalance(BalanceFilter filter);

void CreateContract(ContractEntity newContract);
void DeleteContract(UInt160 contractHash, UInt256 txId, DateTime time);
void MigrateContract(ContractEntity migrateContract);
IEnumerable<ContractEntity> GetAllContracts();

ContractEntity GetActiveContract(UInt160 contract);
ContractEntity GetActiveContract(string contractHash);
ContractEntity GetContract(long id);
AddressEntity GetAddress(long id);
void Commit();
}

public class SQLiteRepository : IRepository
{
private SQLiteContext _db;

public SQLiteRepository(string path)
{
_db = new SQLiteContext(path);
}
public byte[] Identity => _db.Identity;
public uint? GetMaxSyncIndex()
{
return _db.GetMaxSyncIndex();
}

public void AddSyncIndex(uint index)
{
_db.Add(new SyncIndex() { BlockHeight = index });
}

//public void SetMaxSyncIndex(uint height)
//{
// throw new NotImplementedException();
//}

public void AddTransfer(TransferInfo transfer)
{
//var from = GetOrCreateAddress(transfer.From);
//var to = GetOrCreateAddress(transfer.To);
//var asset = GetActiveContract(transfer.Asset);

//var tran = new TransferEntity
//{
// BlockHeight = transfer.BlockHeight,
// TxId = transfer.TxId?.ToBigEndianHex(),
// FromId = from?.Id,
// ToId = to?.Id,
// Amount = transfer.Amount.ToByteArray(),
// AssetId = asset.Id,
// Time = transfer.TimeStamp.FromTimestampMS(),
// Trigger = transfer.Trigger,
// TokenId = transfer.TokenId,
//};
//_db.Transfers.Add(tran);
}

public void AddTransaction(TransactionInfo transaction)
{
throw new NotImplementedException();
}

public void UpdateBalance(UInt160 addressHash, UInt160 assetHash, BigInteger balance, uint height)
{
throw new NotImplementedException();
}

public PageList<TransactionInfo> QueryTransactions(TransactionFilter filter, bool includeTransfers = false)
{
throw new NotImplementedException();
}

public IEnumerable<BalanceInfo> FindAssetBalance(BalanceFilter filter)
{
throw new NotImplementedException();
}

public void CreateContract(ContractEntity newContract)
{
throw new NotImplementedException();
}

public void DeleteContract(UInt160 contractHash, UInt256 txId, DateTime time)
{
throw new NotImplementedException();
}

public void MigrateContract(ContractEntity migrateContract)
{
throw new NotImplementedException();
}

public IEnumerable<ContractEntity> GetAllContracts()
{
throw new NotImplementedException();
}

public ContractEntity GetActiveContract(UInt160 contract)
{
throw new NotImplementedException();
}

public ContractEntity GetActiveContract(string contractHash)
{
throw new NotImplementedException();
}

public ContractEntity GetContract(long id)
{
throw new NotImplementedException();
}

public AddressEntity GetAddress(long id)
{
throw new NotImplementedException();
}

public void Commit()
{
throw new NotImplementedException();
}
}
4 changes: 4 additions & 0 deletions neo3-gui/neo3-gui/publish.sc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dotnet publish --sc -c Release -o ClientApp/build-neo-node
cd ClientApp
npm install
npm run publish

0 comments on commit 0c86dac

Please sign in to comment.