Skip to content

Commit 799cdd4

Browse files
authored
Merge pull request #5 from GalaxyPay/dev
chore: release v1.1.0
2 parents 95a1269 + 383601b commit 799cdd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+882
-181
lines changed

.github/workflows/go.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
cd AvmWinNode
2121
dotnet publish -o ..\publish
2222
23-
- name: Publish AlgorandService
23+
- name: Publish NodeService
2424
run: |
25-
cd AlgorandService
26-
dotnet publish -o ..\publish\Services -p:PublishSingleFile=true
25+
cd NodeService
26+
dotnet publish -o ..\publish\Services
2727
28-
- name: Publish VoiService
28+
- name: Publish RetiService
2929
run: |
30-
cd VoiService
31-
dotnet publish -o ..\publish\Services -p:PublishSingleFile=true
30+
cd RetiService
31+
dotnet publish -o ..\publish\Services
3232
3333
- name: Install pnpm
3434
uses: pnpm/action-setup@v4
@@ -58,5 +58,5 @@ jobs:
5858
uses: ncipollo/release-action@v1
5959
with:
6060
allowUpdates: true
61-
tag: v1.0.2
61+
tag: v1.1.0
6262
artifacts: "Output\\AvmWinNode_Setup.exe"

AvmWinNode.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "AvmWinNode"
5-
#define MyAppVersion "1.0.2"
5+
#define MyAppVersion "1.1.0"
66
#define MyAppPublisher "Galaxy Pay, LLC"
77
#define MyAppPublisherURL "https://galaxy-pay.com"
88
#define MyPublishPath "publish"

AvmWinNode.sln

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ VisualStudioVersion = 17.11.35222.181
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvmWinNode", "AvmWinNode\AvmWinNode.csproj", "{B7AAC1C0-BF35-4E22-8ADF-24E0B848EBB5}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoiService", "VoiService\VoiService.csproj", "{BF9844E6-0161-49D9-A4AA-B923F9B1F9F7}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeService", "NodeService\NodeService.csproj", "{88D7FF7E-98CA-4781-A3D2-7EA580BB202A}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlgorandService", "AlgorandService\AlgorandService.csproj", "{34F29EAA-983D-40F5-BCB8-5C80DD1F2ADD}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RetiService", "RetiService\RetiService.csproj", "{0C1F4DFB-0EE3-47B9-9B91-CD3431CC343D}"
1111
EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,14 +19,14 @@ Global
1919
{B7AAC1C0-BF35-4E22-8ADF-24E0B848EBB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
2020
{B7AAC1C0-BF35-4E22-8ADF-24E0B848EBB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
2121
{B7AAC1C0-BF35-4E22-8ADF-24E0B848EBB5}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{BF9844E6-0161-49D9-A4AA-B923F9B1F9F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{BF9844E6-0161-49D9-A4AA-B923F9B1F9F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{BF9844E6-0161-49D9-A4AA-B923F9B1F9F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{BF9844E6-0161-49D9-A4AA-B923F9B1F9F7}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{34F29EAA-983D-40F5-BCB8-5C80DD1F2ADD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{34F29EAA-983D-40F5-BCB8-5C80DD1F2ADD}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{34F29EAA-983D-40F5-BCB8-5C80DD1F2ADD}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{34F29EAA-983D-40F5-BCB8-5C80DD1F2ADD}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{88D7FF7E-98CA-4781-A3D2-7EA580BB202A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{88D7FF7E-98CA-4781-A3D2-7EA580BB202A}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{88D7FF7E-98CA-4781-A3D2-7EA580BB202A}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{88D7FF7E-98CA-4781-A3D2-7EA580BB202A}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{0C1F4DFB-0EE3-47B9-9B91-CD3431CC343D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{0C1F4DFB-0EE3-47B9-9B91-CD3431CC343D}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{0C1F4DFB-0EE3-47B9-9B91-CD3431CC343D}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{0C1F4DFB-0EE3-47B9-9B91-CD3431CC343D}.Release|Any CPU.Build.0 = Release|Any CPU
3030
EndGlobalSection
3131
GlobalSection(SolutionProperties) = preSolution
3232
HideSolutionNode = FALSE

AvmWinNode/AvmWinNode.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<None Update="Templates\voi.zip">
3232
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3333
</None>
34+
<None Update="Templates\fnet.zip">
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</None>
3437
</ItemGroup>
3538

3639
</Project>

AvmWinNode/Controllers/AlgorandController.cs

+22-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AlgorandController(ILogger<AlgorandController> logger) : Controller
1414

1515
// GET: algorand
1616
[HttpGet]
17-
public ActionResult<NodeConfig> GetAlgorand()
17+
public async Task<ActionResult<NodeStatus>> GetAlgorand()
1818
{
1919
try
2020
{
@@ -23,15 +23,15 @@ public ActionResult<NodeConfig> GetAlgorand()
2323
int port = int.Parse(net[(net.LastIndexOf(":") + 1)..]);
2424
string token = string.Empty;
2525
try { token = System.IO.File.ReadAllText(_dataPath + @"algorand\algod.admin.token"); } catch { }
26-
string sc = Utils.ExecCmd(@"sc query ""Algorand Node""");
26+
string sc = await Utils.ExecCmd(@"sc query ""Algorand Node""");
2727
string serviceStatus = Utils.ParseServiceStatus(sc);
28-
NodeConfig config = new()
28+
NodeStatus nodeStatus = new()
2929
{
3030
Port = port,
3131
Token = token,
3232
ServiceStatus = serviceStatus
3333
};
34-
return config;
34+
return nodeStatus;
3535
}
3636
catch (Exception ex)
3737
{
@@ -41,15 +41,16 @@ public ActionResult<NodeConfig> GetAlgorand()
4141

4242
// POST: algorand
4343
[HttpPost]
44-
public ActionResult<string> CreateAlgorandService()
44+
public async Task<ActionResult<string>> CreateAlgorandService()
4545
{
4646
try
4747
{
4848
if (!Directory.Exists(_dataPath + "algorand"))
4949
{
50-
Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\algorand.zip"" -C " + _dataPath);
50+
await Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\algorand.zip"" -C " + _dataPath);
5151
}
52-
return Utils.ExecCmd(@"sc create ""Algorand Node"" binPath= """ + AppContext.BaseDirectory + @"Services\AlgorandService.exe"" start= auto");
52+
string binPath = @"""\""" + AppContext.BaseDirectory + @"Services\NodeService.exe\"" algorand""";
53+
return await Utils.ExecCmd(@"sc create ""Algorand Node"" binPath= " + binPath + @" start= auto");
5354
}
5455
catch (Exception ex)
5556
{
@@ -59,12 +60,15 @@ public ActionResult<string> CreateAlgorandService()
5960

6061
// POST: algorand/reset
6162
[HttpPost("reset")]
62-
public ActionResult<string> ResetAlgorandNode()
63+
public async Task<ActionResult<string>> ResetAlgorandNode()
6364
{
6465
try
6566
{
66-
Directory.Delete(_dataPath + "algorand", true);
67-
Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\algorand.zip"" -C " + _dataPath);
67+
if (Directory.Exists(_dataPath + "algorand"))
68+
{
69+
Directory.Delete(_dataPath + "algorand", true);
70+
}
71+
await Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\algorand.zip"" -C " + _dataPath);
6872
return Ok();
6973
}
7074
catch (Exception ex)
@@ -75,7 +79,7 @@ public ActionResult<string> ResetAlgorandNode()
7579

7680
// POST: algorand/catchup
7781
[HttpPost("catchup")]
78-
public ActionResult<string> CatchupAlgorandNode(Catchup model)
82+
public async Task<ActionResult<string>> CatchupAlgorandNode(Catchup model)
7983
{
8084
try
8185
{
@@ -87,7 +91,7 @@ public ActionResult<string> CatchupAlgorandNode(Catchup model)
8791
|| data.Length != 52)
8892
return BadRequest();
8993
string cmd = string.Format(_dataPath + "goal node catchup {0} -d " + _dataPath + "algorand", model.Catchpoint);
90-
return Utils.ExecCmd(cmd);
94+
return await Utils.ExecCmd(cmd);
9195
}
9296
catch (Exception ex)
9397
{
@@ -97,11 +101,11 @@ public ActionResult<string> CatchupAlgorandNode(Catchup model)
97101

98102
// PUT: algorand/start
99103
[HttpPut("start")]
100-
public ActionResult<string> StartAlgorandService()
104+
public async Task<ActionResult<string>> StartAlgorandService()
101105
{
102106
try
103107
{
104-
return Utils.ExecCmd(@"sc start ""Algorand Node""");
108+
return await Utils.ExecCmd(@"sc start ""Algorand Node""");
105109
}
106110
catch (Exception ex)
107111
{
@@ -111,11 +115,11 @@ public ActionResult<string> StartAlgorandService()
111115

112116
// PUT: algorand/stop
113117
[HttpPut("stop")]
114-
public ActionResult<string> StopAlgorandService()
118+
public async Task<ActionResult<string>> StopAlgorandService()
115119
{
116120
try
117121
{
118-
return Utils.ExecCmd(@"sc stop ""Algorand Node""");
122+
return await Utils.ExecCmd(@"sc stop ""Algorand Node""");
119123
}
120124
catch (Exception ex)
121125
{
@@ -125,11 +129,11 @@ public ActionResult<string> StopAlgorandService()
125129

126130
// DELETE: algorand
127131
[HttpDelete]
128-
public ActionResult<string> DeleteAlgorandService()
132+
public async Task<ActionResult<string>> DeleteAlgorandService()
129133
{
130134
try
131135
{
132-
return Utils.ExecCmd(@"sc delete ""Algorand Node""");
136+
return await Utils.ExecCmd(@"sc delete ""Algorand Node""");
133137
}
134138
catch (Exception ex)
135139
{
+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
using AvmWinNode.Models;
2+
using Microsoft.AspNetCore.Mvc;
3+
using static System.Environment;
4+
5+
namespace AvmWinNode.Controllers
6+
{
7+
[ApiController]
8+
[Route("[controller]")]
9+
public class FnetController(ILogger<FnetController> logger) : ControllerBase
10+
{
11+
12+
private readonly ILogger<FnetController> _logger = logger;
13+
private readonly string _dataPath = Path.Combine(GetFolderPath(SpecialFolder.CommonApplicationData), @"AvmWinNode\");
14+
15+
// GET: fnet
16+
[HttpGet]
17+
public async Task<ActionResult<NodeStatus>> GetFnet()
18+
{
19+
try
20+
{
21+
string net = ":0";
22+
try { net = System.IO.File.ReadAllText(_dataPath + @"fnet\algod.net").Replace("\n", ""); } catch { }
23+
int port = int.Parse(net[(net.LastIndexOf(":") + 1)..]);
24+
string token = string.Empty;
25+
try { token = System.IO.File.ReadAllText(_dataPath + @"fnet\algod.admin.token"); } catch { }
26+
string fnetQuery = await Utils.ExecCmd(@"sc query ""Fnet Node""");
27+
string nodeServiceStatus = Utils.ParseServiceStatus(fnetQuery);
28+
29+
// Reti Status
30+
string retiQuery = await Utils.ExecCmd(@"sc query ""Reti Validator""");
31+
string retiServiceStatus = Utils.ParseServiceStatus(retiQuery);
32+
33+
string exePath = _dataPath + @"reti\reti.exe";
34+
string? version = null;
35+
if (System.IO.File.Exists(exePath))
36+
{
37+
version = await Utils.ExecCmd(exePath + " --version");
38+
}
39+
40+
string? exeStatus = null;
41+
if (retiServiceStatus == "Running")
42+
{
43+
try
44+
{
45+
using HttpClient client = new();
46+
var ready = await client.GetAsync("http://localhost:6260/ready");
47+
exeStatus = ready.IsSuccessStatusCode ? "Running" : "Stopped";
48+
}
49+
catch
50+
{
51+
exeStatus = "Stopped";
52+
}
53+
}
54+
55+
RetiStatus retiStatus = new()
56+
{
57+
ServiceStatus = retiServiceStatus,
58+
Version = version,
59+
ExeStatus = exeStatus,
60+
};
61+
62+
NodeStatus nodeStatus = new()
63+
{
64+
ServiceStatus = nodeServiceStatus,
65+
Port = port,
66+
Token = token,
67+
RetiStatus = retiStatus
68+
};
69+
70+
return nodeStatus;
71+
}
72+
catch (Exception ex)
73+
{
74+
return BadRequest(ex.Message);
75+
}
76+
}
77+
78+
// POST: fnet
79+
[HttpPost]
80+
public async Task<ActionResult<string>> CreateFnetService()
81+
{
82+
try
83+
{
84+
if (!Directory.Exists(_dataPath + "fnet"))
85+
{
86+
await Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\fnet.zip"" -C " + _dataPath);
87+
}
88+
string binPath = @"""\""" + AppContext.BaseDirectory + @"Services\NodeService.exe\"" fnet""";
89+
return await Utils.ExecCmd(@"sc create ""Fnet Node"" binPath= " + binPath + @" start= auto");
90+
}
91+
catch (Exception ex)
92+
{
93+
return BadRequest(ex.Message);
94+
}
95+
}
96+
97+
// POST: fnet/reset
98+
[HttpPost("reset")]
99+
public async Task<ActionResult<string>> ResetFnetNode()
100+
{
101+
try
102+
{
103+
if (Directory.Exists(_dataPath + "fnet"))
104+
{
105+
Directory.Delete(_dataPath + "fnet", true);
106+
}
107+
await Utils.ExecCmd(@"tar -xf """ + AppContext.BaseDirectory + @"Templates\fnet.zip"" -C " + _dataPath);
108+
return Ok();
109+
}
110+
catch (Exception ex)
111+
{
112+
return BadRequest(ex.Message);
113+
}
114+
}
115+
116+
// POST: fnet/catchup
117+
[HttpPost("catchup")]
118+
public async Task<ActionResult<string>> CatchupFnetNode(Catchup model)
119+
{
120+
try
121+
{
122+
var round = model.Catchpoint.Split('#')[0];
123+
var data = model.Catchpoint.Split('#')[1];
124+
if (string.IsNullOrEmpty(model.Catchpoint)
125+
|| model.Catchpoint.Any(Char.IsWhiteSpace)
126+
|| !int.TryParse(round, out _)
127+
|| data.Length != 52)
128+
return BadRequest();
129+
string cmd = string.Format(_dataPath + "goal node catchup {0} -d " + _dataPath + "fnet", model.Catchpoint);
130+
return await Utils.ExecCmd(cmd);
131+
}
132+
catch (Exception ex)
133+
{
134+
return BadRequest(ex.Message);
135+
}
136+
}
137+
138+
// PUT: fnet/start
139+
[HttpPut("start")]
140+
public async Task<ActionResult<string>> StartFnetService()
141+
{
142+
try
143+
{
144+
return await Utils.ExecCmd(@"sc start ""Fnet Node""");
145+
}
146+
catch (Exception ex)
147+
{
148+
return BadRequest(ex.Message);
149+
}
150+
}
151+
152+
// PUT: fnet/stop
153+
[HttpPut("stop")]
154+
public async Task<ActionResult<string>> StopFnetService()
155+
{
156+
try
157+
{
158+
return await Utils.ExecCmd(@"sc stop ""Fnet Node""");
159+
}
160+
catch (Exception ex)
161+
{
162+
return BadRequest(ex.Message);
163+
}
164+
}
165+
166+
// DELETE: fnet
167+
[HttpDelete]
168+
public async Task<ActionResult<string>> DeleteFnetService()
169+
{
170+
try
171+
{
172+
return await Utils.ExecCmd(@"sc delete ""Fnet Node""");
173+
}
174+
catch (Exception ex)
175+
{
176+
return BadRequest(ex.Message);
177+
}
178+
}
179+
}
180+
}

0 commit comments

Comments
 (0)