Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Chaning size_t to uint64_t
Browse files Browse the repository at this point in the history
  • Loading branch information
xcthulhu committed Mar 16, 2015
1 parent 0ac096d commit 42fd121
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/libethash/data_sizes.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
// Sow[i*HashBytes]; j++]]]][[2]][[1]]


static const size_t dag_sizes[2048] = {
static const uint64_t dag_sizes[2048] = {
1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U,
1115684224U, 1124070016U, 1132461952U, 1140849536U, 1149232768U,
1157627776U, 1166013824U, 1174404736U, 1182786944U, 1191180416U,
Expand Down Expand Up @@ -477,7 +477,7 @@ static const size_t dag_sizes[2048] = {
// While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]]

const size_t cache_sizes[2048] = {
const uint64_t cache_sizes[2048] = {
16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U,
17693888U, 17824192U, 17955904U, 18087488U, 18218176U, 18349504U, 18481088U,
18611392U, 18742336U, 18874304U, 19004224U, 19135936U, 19267264U, 19398208U,
Expand Down
8 changes: 4 additions & 4 deletions src/libethash/ethash.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ extern "C" {
#endif

typedef struct ethash_params {
size_t full_size; // Size of full data set (in bytes, multiple of mix size (128)).
size_t cache_size; // Size of compute cache (in bytes, multiple of node size (64)).
uint64_t full_size; // Size of full data set (in bytes, multiple of mix size (128)).
uint64_t cache_size; // Size of compute cache (in bytes, multiple of node size (64)).
} ethash_params;

typedef struct ethash_return_value {
uint8_t result[32];
uint8_t mix_hash[32];
} ethash_return_value;

size_t ethash_get_datasize(const uint32_t block_number);
size_t ethash_get_cachesize(const uint32_t block_number);
uint64_t ethash_get_datasize(const uint32_t block_number);
uint64_t ethash_get_cachesize(const uint32_t block_number);

// Initialize the Parameters
static inline int ethash_params_init(ethash_params *params, const uint32_t block_number) {
Expand Down
4 changes: 2 additions & 2 deletions src/libethash/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
#include "sha3.h"
#endif // WITH_CRYPTOPP

size_t ethash_get_datasize(const uint32_t block_number) {
uint64_t ethash_get_datasize(const uint32_t block_number) {
if (block_number / EPOCH_LENGTH >= 2048)
return 0;
return dag_sizes[block_number / EPOCH_LENGTH];
}

size_t ethash_get_cachesize(const uint32_t block_number) {
uint64_t ethash_get_cachesize(const uint32_t block_number) {
if (block_number / EPOCH_LENGTH >= 2048)
return 0;
return cache_sizes[block_number / EPOCH_LENGTH];
Expand Down
14 changes: 7 additions & 7 deletions src/python/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mkcache_bytes(PyObject *self, PyObject *args) {
}

ethash_params params;
params.cache_size = (size_t) cache_size;
params.cache_size = (uint64_t) cache_size;
ethash_cache cache;
cache.mem = malloc(cache_size);
ethash_mkcache(&cache, &params, (uint8_t *) seed);
Expand Down Expand Up @@ -92,8 +92,8 @@ calc_dataset_bytes(PyObject *self, PyObject *args) {
}

ethash_params params;
params.cache_size = (size_t) cache_size;
params.full_size = (size_t) full_size;
params.cache_size = (uint64_t) cache_size;
params.full_size = (uint64_t) full_size;
ethash_cache cache;
cache.mem = (void *) cache_bytes;
void *mem = malloc(params.full_size);
Expand Down Expand Up @@ -138,8 +138,8 @@ hashimoto_light(PyObject *self, PyObject *args) {

ethash_return_value out;
ethash_params params;
params.cache_size = (size_t) cache_size;
params.full_size = (size_t) full_size;
params.cache_size = (uint64_t) cache_size;
params.full_size = (uint64_t) full_size;
ethash_cache cache;
cache.mem = (void *) cache_bytes;
ethash_light(&out, &cache, &params, (uint8_t *) header, nonce);
Expand Down Expand Up @@ -175,7 +175,7 @@ hashimoto_full(PyObject *self, PyObject *args) {

ethash_return_value out;
ethash_params params;
params.full_size = (size_t) full_size;
params.full_size = (uint64_t) full_size;
ethash_full(&out, (void *) full_bytes, &params, (uint8_t *) header, nonce);
return Py_BuildValue("{s:s#, s:s#}",
"mix digest", out.mix_hash, 32,
Expand Down Expand Up @@ -216,7 +216,7 @@ mine(PyObject *self, PyObject *args) {

ethash_return_value out;
ethash_params params;
params.full_size = (size_t) full_size;
params.full_size = (uint64_t) full_size;

// TODO: Multi threading?
do {
Expand Down
2 changes: 1 addition & 1 deletion test/c/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <boost/test/unit_test.hpp>
#include <iostream>

std::string bytesToHexString(const uint8_t *str, const size_t s) {
std::string bytesToHexString(const uint8_t *str, const uint32_t s) {
std::ostringstream ret;

for (int i = 0; i < s; ++i)
Expand Down

0 comments on commit 42fd121

Please sign in to comment.