Skip to content

Commit 86e7a56

Browse files
committed
Merge 'master' from xdag.me/xdag.git
Updates from version T13.856 to T13.865.
1 parent 7239f5c commit 86e7a56

7 files changed

Lines changed: 42 additions & 37 deletions

File tree

client/block.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* работа с блоками, T13.654-T13.856 $DVS:time$ */
1+
/* работа с блоками, T13.654-T13.864 $DVS:time$ */
22

33
#include <stdlib.h>
44
#include <stdio.h>
@@ -827,7 +827,7 @@ int cheatcoin_blocks_reset(void) {
827827
return 0;
828828
}
829829

830-
#define pramount(amount) (uint32_t)((amount) >> 32), (uint32_t)((((amount) & 0xffffffffull) * 1000000000) >> 32)
830+
#define pramount(amount) xdag_amount2xdag(amount), xdag_amount2cheato(amount)
831831

832832
static int bi_compar(const void *l, const void *r) {
833833
cheatcoin_time_t tl = (*(struct block_internal **)l)->time, tr = (*(struct block_internal **)r)->time;
@@ -853,14 +853,14 @@ int cheatcoin_print_block_info(cheatcoin_hash_t hash, FILE *out) {
853853
strftime(tbuf, 64, "%Y-%m-%d %H:%M:%S", &tm);
854854
fprintf(out, " time: %s.%03d\n", tbuf, (int)((bi->time & 0x3ff) * 1000) >> 10);
855855
fprintf(out, " timestamp: %llx\n", (unsigned long long)bi->time);
856-
fprintf(out, " flags: %x\n", bi->flags);
856+
fprintf(out, " flags: %x\n", bi->flags & ~BI_OURS);
857857
fprintf(out, " file pos: %llx\n", (unsigned long long)bi->storage_pos);
858858
fprintf(out, " hash: %016llx%016llx%016llx%016llx\n",
859859
(unsigned long long)h[3], (unsigned long long)h[2], (unsigned long long)h[1], (unsigned long long)h[0]);
860860
fprintf(out, "difficulty: %llx%016llx\n", cheatcoin_diff_args(bi->difficulty));
861861
fprintf(out, " balance: %s %10u.%09u\n", cheatcoin_hash2address(h), pramount(bi->amount));
862862
fprintf(out, "-------------------------------------------------------------------------------------------\n");
863-
fprintf(out, "block as transaction: details\n");
863+
fprintf(out, " block as transaction: details\n");
864864
fprintf(out, " direction address amount\n");
865865
fprintf(out, "-------------------------------------------------------------------------------------------\n");
866866
fprintf(out, " fee: %s %10u.%09u\n", (bi->ref ? cheatcoin_hash2address(bi->ref->hash) : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"),
@@ -869,7 +869,7 @@ int cheatcoin_print_block_info(cheatcoin_hash_t hash, FILE *out) {
869869
fprintf(out, " %6s: %s %10u.%09u\n", (1 << i & bi->in_mask ? " input" : "output"),
870870
cheatcoin_hash2address(bi->link[i]->hash), pramount(bi->linkamount[i]));
871871
fprintf(out, "-------------------------------------------------------------------------------------------\n");
872-
fprintf(out, "block as address: details\n");
872+
fprintf(out, " block as address: details\n");
873873
fprintf(out, " direction transaction amount time \n");
874874
fprintf(out, "-------------------------------------------------------------------------------------------\n");
875875
if (bi->flags & BI_MAIN)

client/hash.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* хеш-функция, T13.654-T13.847 $DVS:time$ */
1+
/* хеш-функция, T13.654-T13.864 $DVS:time$ */
22

33
#include <string.h>
44
#ifdef SHA256_OPENSSL_MBLOCK
@@ -87,6 +87,7 @@ uint64_t cheatcoin_hash_final_multi(void *ctxv, uint64_t *nonce, int attempts, i
8787
uint8_t *array1 = (uint8_t *)arr1, *array2 = (uint8_t *)arr2;
8888
cheatcoin_hash_t hash0;
8989
uint64_t min_nonce = 0, nonce0;
90+
uint32_t *hash032 = (uint32_t *)(uint64_t *)hash0;
9091
int i, j;
9192

9293
memset(array1, 0, 128);
@@ -132,14 +133,14 @@ uint64_t cheatcoin_hash_final_multi(void *ctxv, uint64_t *nonce, int attempts, i
132133
memcpy(&mctx, &mctx2, 8 * 8 * 4);
133134
xsha256_multi_block(&mctx, desc2, N/4);
134135
for (i = 0; i < N; ++i, nonce0 += step) {
135-
((uint32_t *)hash0)[0] = htonl(mctx.A[i]);
136-
((uint32_t *)hash0)[1] = htonl(mctx.B[i]);
137-
((uint32_t *)hash0)[2] = htonl(mctx.C[i]);
138-
((uint32_t *)hash0)[3] = htonl(mctx.D[i]);
139-
((uint32_t *)hash0)[4] = htonl(mctx.E[i]);
140-
((uint32_t *)hash0)[5] = htonl(mctx.F[i]);
141-
((uint32_t *)hash0)[6] = htonl(mctx.G[i]);
142-
((uint32_t *)hash0)[7] = htonl(mctx.H[i]);
136+
hash032[0] = htonl(mctx.A[i]);
137+
hash032[1] = htonl(mctx.B[i]);
138+
hash032[2] = htonl(mctx.C[i]);
139+
hash032[3] = htonl(mctx.D[i]);
140+
hash032[4] = htonl(mctx.E[i]);
141+
hash032[5] = htonl(mctx.F[i]);
142+
hash032[6] = htonl(mctx.G[i]);
143+
hash032[7] = htonl(mctx.H[i]);
143144
if ((!i && !j) || cheatcoin_cmphash(hash0, hash) < 0) {
144145
memcpy(hash, hash0, sizeof(cheatcoin_hash_t));
145146
min_nonce = nonce0;

client/main.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* cheatcoin main, T13.654-T13.855 $DVS:time$ */
1+
/* cheatcoin main, T13.654-T13.865 $DVS:time$ */
22

33
#include <stdio.h>
44
#include <stdlib.h>
@@ -16,7 +16,12 @@
1616
#include <sys/socket.h>
1717
#include <sys/un.h>
1818
#include <errno.h>
19+
#elif defined(_WIN64)
20+
#define poll WSAPoll
21+
#else
22+
#define poll(a,b,c) ((a)->revents = (a)->events, (b))
1923
#endif
24+
#include "system.h"
2025
#include "address.h"
2126
#include "block.h"
2227
#include "crypt.h"
@@ -60,13 +65,7 @@ struct cheatcoin_ext_stats g_cheatcoin_extstats;
6065
int (*g_cheatcoin_show_state)(const char *state, const char *balance, const char *address) = 0;
6166

6267
static long double amount2cheatcoins(cheatcoin_amount_t amount) {
63-
long double res = 0, d = 1;
64-
int i;
65-
for (i = 0; i < 32 || (amount && i < 64); ++i, amount >>= 1) {
66-
if (amount & 1) res += d;
67-
if (i < 32) res /= 2; else d *= 2;
68-
}
69-
return floorl(res * 1000000000) / 1000000000;
68+
return xdag_amount2xdag(amount) + (long double)xdag_amount2cheato(amount) / 1000000000;
7069
}
7170

7271
static long double diff2log(cheatcoin_diff_t diff) {
@@ -88,16 +87,13 @@ static long double hashrate(cheatcoin_diff_t *diff) {
8887
static cheatcoin_amount_t cheatcoins2amount(const char *str) {
8988
long double sum, flr;
9089
cheatcoin_amount_t res;
91-
int i;
9290
if (sscanf(str, "%Lf", &sum) != 1 || sum <= 0) return 0;
9391
flr = floorl(sum);
9492
res = (cheatcoin_amount_t)flr << 32;
9593
sum -= flr;
96-
for (i = 31; i >= 0; --i) {
97-
sum *= 2;
98-
if (sum >= 1) res |= 1ll << i, sum--;
99-
}
100-
return res;
94+
sum = ldexpl(sum, 32);
95+
flr = ceill(sum);
96+
return res + (cheatcoin_amount_t)flr;
10197
}
10298

10399
static int account_callback(void *data, cheatcoin_hash_t hash, cheatcoin_amount_t amount, cheatcoin_time_t time, int n_our_key) {
@@ -391,7 +387,6 @@ static int out_balances(void) {
391387

392388
static int terminal(void) {
393389
#if !defined(_WIN32) && !defined(_WIN64)
394-
// char cmd[CHEATCOIN_COMMAND_MAX], cmd2[CHEATCOIN_COMMAND_MAX], *ptr, *lasts;
395390
char *cmd, *cmd2, *ptr, *lasts;
396391
int s;
397392
struct sockaddr_un addr;
@@ -424,12 +419,16 @@ static int terminal(void) {
424419
while (read(s, &c, 1) == 1 && c) putchar(c);
425420
close(s);
426421
}
422+
423+
free(cmd);
424+
free(cmd2);
425+
427426
#endif
428427
return 0;
429428
}
430429

431-
static void *terminal_thread(void *arg) {
432430
#if !defined(_WIN32) && !defined(_WIN64)
431+
static void *terminal_thread(void *arg) {
433432
struct sockaddr_un addr;
434433
int s;
435434
if( (s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { cheatcoin_err("Can't create unix domain socket errno:%d", errno); return 0; }
@@ -459,11 +458,9 @@ static void *terminal_thread(void *arg) {
459458
if (res < 0) exit(0);
460459
}
461460
}
462-
#else
463461
return 0;
464-
#endif /* WIN */
465462
}
466-
463+
#endif /* WIN */
467464

468465
#ifdef CHEATCOINWALLET
469466
int cheatcoin_main(int argc, char **argv) {
@@ -609,14 +606,14 @@ int main(int argc, char **argv) {
609606
cheatcoin_mess("Starting pool engine...");
610607
if (cheatcoin_pool_start(is_pool, pool_arg, miner_address)) return -1;
611608
#ifndef CHEATCOINWALLET
609+
#if !defined(_WIN32) && !defined(_WIN64)
612610
cheatcoin_mess("Starting terminal server...");
613611
if (pthread_create(&th, 0, &terminal_thread, 0)) return -1;
614-
612+
#endif
615613
if (!(transport_flags & CHEATCOIN_DAEMON)) printf("Type command, help for example.\n");
616614
for(;;) {
617615
if (transport_flags & CHEATCOIN_DAEMON) sleep(100);
618616
else {
619-
// char cmd[CHEATCOIN_COMMAND_MAX];
620617
char *cmd;
621618
cmd = malloc(CHEATCOIN_COMMAND_MAX);
622619
printf("%s> ", g_progname); fflush(stdout);

client/main.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* основные переменные, T13.714-T13.819 $DVS:time$ */
1+
/* основные переменные, T13.714-T13.865 $DVS:time$ */
22

33
#ifndef CHEATCOIN_MAIN_H
44
#define CHEATCOIN_MAIN_H
@@ -69,4 +69,7 @@ extern "C" {
6969
};
7070
#endif
7171

72+
#define xdag_amount2xdag(amount) ((unsigned)((amount) >> 32))
73+
#define xdag_amount2cheato(amount) ((unsigned)(((uint64_t)(unsigned)(amount) * 1000000000) >> 32))
74+
7275
#endif

client/netdb-white.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
66.11.125.30:888
1818
45.77.35.21:8900
1919
148.251.139.197:16800
20+
139.99.124.121:8900
2021

client/netdb.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
66.11.125.30:888
1818
45.77.35.21:8900
1919
148.251.139.197:16800
20+
139.99.124.121:8900
2021

client/version.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
#ifndef CHEATCOIN_VERSION_H
44
#define CHEATCOIN_VERSION_H
55

6-
#define CHEATCOIN_VERSION "T13.654-T13.856" /* $DVS:time$ */
6+
#define CHEATCOIN_VERSION "T13.654-T13.865" /* $DVS:time$ */
77

88
/* история
99
10+
T13.865 исправлена ошибка с перечислением дробных сумм
11+
1012
T13.856 добавлена команда block, показывающая информацию о блоке
1113
1214
T13.853 коммуникация через fifo заменена на сокеты unix

0 commit comments

Comments
 (0)