Skip to content

Commit

Permalink
version T13.895: more accurate faster tx; 4 hours hashrate average; f…
Browse files Browse the repository at this point in the history
…ixed mem leak, crashes by sig 15, 28; whitelist
  • Loading branch information
Daniel Cheatoshin committed Feb 10, 2018
1 parent 55053ef commit f1976a0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
15 changes: 8 additions & 7 deletions cheatcoin/block.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* работа с блоками, T13.654-T13.889 $DVS:time$ */
/* работа с блоками, T13.654-T13.895 $DVS:time$ */

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -217,7 +217,7 @@ static void check_new_main(void) {
int i;
for (b = top_main_chain, i = 0; b && !(b->flags & BI_MAIN); b = b->link[b->max_diff_link])
if (b->flags & BI_MAIN_CHAIN) p = b, ++i;
if (p && i > MAX_WAITING_MAIN) set_main(p);
if (p && i > MAX_WAITING_MAIN && get_timestamp() >= p->time + 2 * 1024) set_main(p);
}

static void unwind_main(struct block_internal *b) {
Expand Down Expand Up @@ -662,7 +662,7 @@ static void *work_thread(void *arg) {
if (!g_light_mode && t - conn_time >= 2 * MAIN_CHAIN_PERIOD
&& !memcmp(&g_cheatcoin_stats.difficulty, &g_cheatcoin_stats.max_difficulty, sizeof(cheatcoin_diff_t)))
sync_time = t;
if (t - (g_cheatcoin_xfer_last << 10) <= (g_light_mode ? 4 : 3) * MAIN_CHAIN_PERIOD)
if (t - (g_cheatcoin_xfer_last << 10) <= 2 * MAIN_CHAIN_PERIOD + 4)
g_cheatcoin_state = CHEATCOIN_STATE_XFER;
else if (g_light_mode) {
g_cheatcoin_state = (g_cheatcoin_mining_threads > 0 ?
Expand Down Expand Up @@ -836,7 +836,7 @@ static int bi_compar(const void *l, const void *r) {

/* вывести подробную информацию о блоке */
int cheatcoin_print_block_info(cheatcoin_hash_t hash, FILE *out) {
struct block_internal *bi, **ba, *ri;
struct block_internal *bi, **ba, **ba1, *ri;
struct block_backrefs *br;
struct tm tm;
char tbuf[64];
Expand Down Expand Up @@ -884,13 +884,14 @@ int cheatcoin_print_block_info(cheatcoin_hash_t hash, FILE *out) {
if (!i) continue;
if (n + i > N) {
N *= 2;
ba = realloc(ba, N * sizeof(struct block_internal *));
if (!ba) return -1;
ba1 = realloc(ba, N * sizeof(struct block_internal *));
if (!ba1) { free(ba); return -1; }
ba = ba1;
}
memcpy(ba + n, br->backrefs, i * sizeof(struct block_internal *));
n += i;
}
if (!n) return 0;
if (!n) { free(ba); return 0; }
qsort(ba, n, sizeof(struct block_internal *), bi_compar);
for (i = 0; i < n; ++i) if (!i || ba[i] != ba[i - 1]) {
ri = ba[i];
Expand Down
4 changes: 2 additions & 2 deletions cheatcoin/log.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* логирование, T13.670-T13.811 $DVS:time$ */
/* логирование, T13.670-T13.895 $DVS:time$ */

#include <stdio.h>
#include <stdint.h>
Expand Down Expand Up @@ -109,7 +109,7 @@ int cheatcoin_log_init(void) {
sigemptyset (&sa.sa_mask);
sa.sa_flags = SA_RESTART | SA_SIGINFO;
for (i = 1; i < 32; ++i) {
if (i != SIGURG && i != SIGCHLD && i != SIGCONT && i != SIGPIPE) {
if (i != SIGURG && i != SIGCHLD && i != SIGCONT && i != SIGPIPE && i != SIGINT && i != SIGTERM && i != SIGWINCH && i != SIGHUP) {
sigaction(i, &sa, 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions cheatcoin/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* cheatcoin main, T13.654-T13.865 $DVS:time$ */
/* cheatcoin main, T13.654-T13.895 $DVS:time$ */

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -306,7 +306,7 @@ static int cheatcoin_command(char *cmd, FILE *out) {
" wait sync blocks: %u\n"
" chain difficulty: %llx%016llx of %llx%016llx\n"
" %9s supply: %.9Lf of %.9Lf\n"
"hour hashrate MHs: %.2Lf of %.2Lf\n",
"4 hr hashrate MHs: %.2Lf of %.2Lf\n",
g_cheatcoin_stats.nhosts, g_cheatcoin_stats.total_nhosts,
(long long)g_cheatcoin_stats.nblocks, (long long)g_cheatcoin_stats.total_nblocks,
(long long)g_cheatcoin_stats.nmain, (long long)g_cheatcoin_stats.total_nmain,
Expand Down
4 changes: 2 additions & 2 deletions cheatcoin/main.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* основные переменные, T13.714-T13.865 $DVS:time$ */
/* основные переменные, T13.714-T13.895 $DVS:time$ */

#ifndef CHEATCOIN_MAIN_H
#define CHEATCOIN_MAIN_H
Expand All @@ -22,7 +22,7 @@ extern struct cheatcoin_stats {
uint32_t nhosts, total_nhosts, reserved1, reserved2;
} g_cheatcoin_stats;

#define HASHRATE_LAST_MAX_TIME 64
#define HASHRATE_LAST_MAX_TIME (64 * 4)

extern struct cheatcoin_ext_stats {
cheatcoin_diff_t hashrate_total[HASHRATE_LAST_MAX_TIME];
Expand Down
3 changes: 3 additions & 0 deletions cheatcoin/netdb-white.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
51.15.197.120:13655
188.95.248.247:13655
47.89.176.228:13655
47.52.203.23:13655
58.218.204.118:13655
39.104.88.224:13655

3 changes: 3 additions & 0 deletions cheatcoin/netdb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
51.15.197.120:13655
188.95.248.247:13655
47.89.176.228:13655
47.52.203.23:13655
58.218.204.118:13655
39.104.88.224:13655

4 changes: 2 additions & 2 deletions cheatcoin/pool.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* пул и майнер, T13.744-T13.837 $DVS:time$ */
/* пул и майнер, T13.744-T13.895 $DVS:time$ */

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -211,7 +211,7 @@ static void *pool_main_thread(void *arg) {
m->ntask = ntask;
nfld = 2;
memcpy(data, task->task, nfld * sizeof(struct cheatcoin_field));
} else if (!(m->state & MINER_BALANCE)) {
} else if (!(m->state & MINER_BALANCE) && time(0) >= (m->main_time << 6) + 4) {
m->state |= MINER_BALANCE;
memcpy(data[0].data, m->id.data, sizeof(cheatcoin_hash_t));
data[0].amount = cheatcoin_get_balance(data[0].data);
Expand Down
6 changes: 5 additions & 1 deletion cheatcoin/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#ifndef CHEATCOIN_VERSION_H
#define CHEATCOIN_VERSION_H

#define CHEATCOIN_VERSION "T13.654-T13.889" /* $DVS:time$ */
#define CHEATCOIN_VERSION "T13.654-T13.895" /* $DVS:time$ */

/* история
T13.895 более аккуратное сокращение времени прохождения транзакции (132 сек максимум);
статистика теперь усредняется по 4-часовому интервалу; более аккуратное
устранение утечки памяти; исправлены падения по сигналам 15, 28
T13.889 время подтверждения транзакции сокращено на минуту, устранена утечка памяти,
исправлена ошибка с падением при переинициализации системы блоков
Expand Down

0 comments on commit f1976a0

Please sign in to comment.