Skip to content

Commit 6704ccc

Browse files
committed
Add processor and gpu name detection
1 parent e130c0d commit 6704ccc

File tree

355 files changed

+101714
-15978
lines changed

Some content is hidden

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

355 files changed

+101714
-15978
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ If you want to learn more, please feel free to go to [the wiki.](https://github.
1212

1313
## Installation / Use:
1414
1. First, either clone with `git clone https://github.com/sam-astro/Distributed-Compute-Coin` or download it as a ZIP file, and extract it.
15-
2. All of the builds are packaged in this folder. They all follow the same directory map, and the binary is located at `dcc_client/out-linux/dcc_client/dcc_client`.
16-
3. A change from the C# version, is that all functionality is now combined into a single program, which can handle transactions, submitting programs, and mining. It is also currently a command-line only interface while in development.
17-
4. **If you are interested in earning Aether, then you can use the Mining aspect of the client.** The miner verifies the blockchain network, and also run programs created by developers. The miner utilizes containers to keep any run programs separate from your own computer. It utilizes **Podman**, an open source, secure, and light-weight alternative to Docker. You can install Podman by going to the [Podman website](https://podman.io/) and following the instructions there, which should only take a few minutes. Just use the `--mine` command to start mining a single block. You can also specify how many blocks you want to mine after the command like: `--mine 10` will mine 10 blocks. Using `-1` will mine until you stop the program.
15+
2. Install requirements, which are: `inxi podman`
16+
3. All of the builds are packaged in this folder. They all follow the same directory map, and the binary is located at `dcc_client/out-linux/dcc_client/dcc_client`.
17+
4. A change from the C# version, is that all functionality is now combined into a single program, which can handle transactions, submitting programs, and mining. It is also currently a command-line only interface while in development.
18+
5. **If you are interested in earning Aether, then you can use the Mining aspect of the client.** The miner verifies the blockchain network, and also run programs created by developers. The miner utilizes containers to keep any run programs separate from your own computer. It utilizes **Podman**, an open source, secure, and light-weight alternative to Docker. You can install Podman by going to the [Podman website](https://podman.io/) and following the instructions there, which should only take a few minutes. Just use the `--mine` command to start mining a single block. You can also specify how many blocks you want to mine after the command like: `--mine 10` will mine 10 blocks. Using `-1` will mine until you stop the program.
1819
```
1920
Usage: aetherdaemon [options]
2021
OR (while in interactive mode)
@@ -176,4 +177,4 @@ Supercomputers are expensive to build, and equally as expensive for institutions
176177
<!----------------------------------[ Badges ]--------------------------------->
177178

178179
[Badge License]: https://img.shields.io/badge/license-DCP--GPL-brightgreen
179-
[Button Discord]: https://img.shields.io/badge/Discord_Server-573f75.svg?style=social&logo=Discord
180+
[Button Discord]: https://img.shields.io/badge/Discord_Server-573f75.svg?style=social&logo=Discord

dcc_client/dcc_client/Main.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ std::string peerPort = "";
4343

4444
unsigned long long flops = 0;
4545

46+
std::string processorName;
47+
std::string gpuName;
48+
4649
//int transactionNumber = 0;
4750

4851
//Console console;
@@ -64,12 +67,19 @@ int main()
6467
console::SystemPrint();
6568
console::WriteLine("Benchmarking... ");
6669
flops = benchmark();
70+
processorName = TrimString(GetStdoutFromCommand("lscpu | grep 'Model name' | cut -f 2 -d \":\" | awk '{$1=$1}1'"));
71+
gpuName = TrimString(GetStdoutFromCommand("inxi -G | grep -i 'opengl.*renderer' | sed -n 's/.*renderer:.*(\\(.*\\)).*/\\1/p'"));
72+
6773
std::cout << " \r";
6874
console::SystemPrint();
6975
console::Write("Benchmark results: ");
7076
console::Write(truncateMetricNum(flops) + "Flops", console::cyanFGColor);
7177
console::Write(" across ");
7278
console::Write(std::to_string(processor_count) + " cores", console::cyanFGColor);
79+
console::Write(" on ");
80+
console::Write(processorName, console::cyanFGColor);
81+
console::Write(", also with unmeasured ");
82+
console::Write(gpuName, console::cyanFGColor);
7383
console::WriteLine(" ok", console::greenFGColor);
7484

7585
if (WalletSettingValues::verbose >= 6) {

dcc_client/dcc_client/Session.vim

+39-78
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-
33
let v:this_session=expand("<sfile>:p")
44
silent only
55
silent tabonly
6-
cd ~/Code/Distributed-Compute-Coin/dcc_client/dcc_client
6+
cd ~/Code/AetherGrid/dcc_client/dcc_client
77
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
88
let s:wipebuf = bufnr('%')
99
endif
@@ -29,6 +29,8 @@ badd +255 Console.cpp
2929
badd +1 strops.cpp
3030
badd +1 term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash
3131
badd +12 ~/Code/Distributed-Compute-Coin/dcc_client/out-linux/dcc_client/out.txt
32+
badd +28 System.cpp
33+
badd +12 System.h
3234
argglobal
3335
%argdel
3436
$argadd P2PClient.cpp
@@ -80,62 +82,44 @@ normal! zo
8082
normal! zo
8183
266
8284
normal! zo
83-
350
85+
436
8486
normal! zo
85-
351
87+
460
8688
normal! zo
87-
444
89+
480
8890
normal! zo
89-
464
91+
497
9092
normal! zo
91-
481
93+
499
9294
normal! zo
93-
483
94-
normal! zo
95-
501
96-
normal! zo
97-
524
98-
normal! zo
99-
528
100-
normal! zo
101-
536
102-
normal! zo
103-
570
104-
normal! zo
105-
576
106-
normal! zo
107-
583
108-
normal! zo
109-
604
110-
normal! zo
111-
639
95+
540
11296
normal! zo
113-
673
97+
586
11498
normal! zo
115-
681
99+
599
116100
normal! zo
117-
691
101+
632
118102
normal! zo
119-
760
103+
655
120104
normal! zo
121-
784
105+
689
122106
normal! zo
123-
788
107+
707
124108
normal! zo
125-
810
109+
776
126110
normal! zo
127-
821
111+
800
128112
normal! zo
129-
822
113+
826
130114
normal! zo
131-
1158
115+
837
132116
normal! zo
133-
let s:l = 523 - ((9 * winheight(0) + 28) / 56)
117+
let s:l = 524 - ((11 * winheight(0) + 28) / 56)
134118
if s:l < 1 | let s:l = 1 | endif
135119
keepjumps exe s:l
136120
normal! zt
137-
keepjumps 523
138-
normal! 051|
121+
keepjumps 524
122+
normal! 033|
139123
tabnext
140124
edit P2PClient.h
141125
argglobal
@@ -372,58 +356,33 @@ setlocal fdl=99
372356
setlocal fml=1
373357
setlocal fdn=20
374358
setlocal fen
375-
58
376-
normal! zo
377-
114
359+
61
378360
normal! zo
379361
124
380362
normal! zo
381-
205
363+
332
382364
normal! zo
383-
207
365+
343
384366
normal! zo
385-
322
367+
356
386368
normal! zo
387-
333
369+
425
388370
normal! zo
389-
346
371+
579
390372
normal! zo
391-
415
373+
742
392374
normal! zo
393-
423
375+
758
394376
normal! zo
395-
428
396-
normal! zo
397-
578
398-
normal! zo
399-
581
400-
normal! zo
401-
617
402-
normal! zo
403-
726
404-
normal! zo
405-
730
406-
normal! zo
407-
746
408-
normal! zo
409-
761
410-
normal! zo
411-
762
412-
normal! zo
413-
771
414-
normal! zo
415-
let s:l = 574 - ((24 * winheight(0) + 28) / 56)
377+
let s:l = 69 - ((27 * winheight(0) + 28) / 56)
416378
if s:l < 1 | let s:l = 1 | endif
417379
keepjumps exe s:l
418380
normal! zt
419-
keepjumps 574
420-
normal! 044|
381+
keepjumps 69
382+
normal! 013|
421383
tabnext
384+
edit term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash
422385
argglobal
423-
if bufexists(fnamemodify("term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash", ":p")) | buffer term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash | else | edit term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash | endif
424-
if &buftype ==# 'terminal'
425-
silent file term://~/Code/Distributed-Compute-Coin/dcc_client/dcc_client//336272:/bin/bash
426-
endif
427386
balt Main.cpp
428387
setlocal fdm=manual
429388
setlocal fde=b:anyfold_ind_buffer[v:lnum-1]
@@ -433,11 +392,13 @@ setlocal fdl=99
433392
setlocal fml=1
434393
setlocal fdn=20
435394
setlocal fen
436-
let s:l = 56 - ((55 * winheight(0) + 28) / 56)
395+
silent! normal! zE
396+
let &fdl = &fdl
397+
let s:l = 1 - ((0 * winheight(0) + 28) / 56)
437398
if s:l < 1 | let s:l = 1 | endif
438399
keepjumps exe s:l
439400
normal! zt
440-
keepjumps 56
401+
keepjumps 1
441402
normal! 0
442403
tabnext
443404
edit SettingsConsts.h
@@ -456,7 +417,7 @@ keepjumps exe s:l
456417
normal! zt
457418
keepjumps 18
458419
normal! 05|
459-
tabnext 1
420+
tabnext 9
460421
set stal=1
461422
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
462423
silent exe 'bwipe ' . s:wipebuf

dcc_client/dcc_client/System.cpp

+23-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "System.h"
33

44

5-
65
// Execute a command in the main thread and print the output
76
std::string ExecuteCommand(const char* cmd, bool printout)
87
{
@@ -15,8 +14,8 @@ std::string ExecuteCommand(const char* cmd, bool printout)
1514
}
1615
while (fgets(buffer.data(), (int)(buffer.size()), pipe.get()) != nullptr) {
1716
result += buffer.data();
18-
if(printout)
19-
std::cout << buffer.data();
17+
if (printout)
18+
std::cout << buffer.data();
2019
}
2120
#else
2221
system(cmd);
@@ -26,17 +25,33 @@ std::string ExecuteCommand(const char* cmd, bool printout)
2625
return "";
2726
}
2827

28+
std::string GetStdoutFromCommand(std::string cmd)
29+
{
30+
std::string data;
31+
FILE* stream;
32+
const int max_buffer = 256;
33+
char buffer[max_buffer];
34+
cmd.append(" 2>&1");
35+
stream = popen(cmd.c_str(), "r");
36+
if (stream) {
37+
while (!feof(stream)) {
38+
if (fgets(buffer, max_buffer, stream) != NULL)
39+
data.append(buffer);
40+
}
41+
pclose(stream);
42+
}
43+
return data;
44+
}
45+
2946
// Execute a process in an asynchronous background thread
3047
boost::process::child ExecuteAsync(std::string cmd, bool printOutput)
3148
{
32-
try
33-
{
49+
try {
3450
namespace bp = boost::process;
3551
std::vector<std::string> splitCommand = SplitString(cmd, " ");
3652
std::string command = splitCommand[0];
3753
std::string args;
38-
for (int i = 1; i < sizeof(splitCommand) / sizeof(splitCommand[0]); i++)
39-
{
54+
for (int i = 1; i < sizeof(splitCommand) / sizeof(splitCommand[0]); i++) {
4055
args += splitCommand[i] + " ";
4156
}
4257

@@ -48,11 +63,9 @@ boost::process::child ExecuteAsync(std::string cmd, bool printOutput)
4863

4964
return c;
5065
}
51-
catch (const std::exception&)
52-
{
66+
catch (const std::exception&) {
5367
return boost::process::child();
5468
}
5569

5670
return boost::process::child();
5771
}
58-

dcc_client/dcc_client/System.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#ifndef SYSTEM_H
22
#define SYSTEM_H
33

4-
#include <string>
5-
#include <cctype>
6-
#include <locale>
74
#include <array>
5+
#include <boost/process.hpp>
6+
#include <cctype>
7+
#include <cstdio>
88
#include <iostream>
9+
#include <locale>
10+
#include <string>
911

10-
#include <boost/process.hpp>
1112
#if defined(_MSC_VER)
12-
#include <boost/process/windows.hpp>
13+
#include <boost/process/windows.hpp>
1314
#endif
1415

1516
#include "strops.h"
1617

17-
std::string ExecuteCommand(const char* cmd, bool printout=true);
18+
std::string ExecuteCommand(const char* cmd, bool printout = true);
1819
boost::process::child ExecuteAsync(std::string cmd, bool printOutput);
20+
std::string GetStdoutFromCommand(std::string cmd);
1921

20-
template <
22+
template<
2123
class result_t = std::chrono::milliseconds,
2224
class clock_t = std::chrono::steady_clock,
23-
class duration_t = std::chrono::milliseconds
24-
>
25+
class duration_t = std::chrono::milliseconds>
2526
auto since(std::chrono::time_point<clock_t, duration_t> const& start)
2627
{
2728
return std::chrono::duration_cast<result_t>(clock_t::now() - start);
2829
}
2930

30-
#endif
31+
#endif

0 commit comments

Comments
 (0)