From 2f77c792a89a9a2078ca7c88f8c8c63f50a05d8e Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 21 Apr 2015 14:46:08 +0200 Subject: [PATCH] ethash_full should not keep cache_size - plus block number is a uint64_t not uint32_t --- ethash.h | 20 ++------------------ internal.c | 21 ++------------------- internal.h | 1 - 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/ethash.h b/ethash.h index 098828e83..61bb72fdb 100644 --- a/ethash.h +++ b/ethash.h @@ -79,8 +79,8 @@ typedef struct ethash_return_value { ethash_h256_t mix_hash; } ethash_return_value; -uint64_t ethash_get_datasize(uint32_t const block_number); -uint64_t ethash_get_cachesize(uint32_t const block_number); +uint64_t ethash_get_datasize(uint64_t const block_number); +uint64_t ethash_get_cachesize(uint64_t const block_number); // LTODO: for consistency's sake maybe use ethash_cache_t? typedef struct ethash_cache { @@ -204,22 +204,6 @@ bool ethash_full_compute( * Get a pointer to the full DAG data */ void *ethash_full_data(ethash_full_t full); -/** - * Get a pointer to the cache object held by the full client - * - * @param full The full client whose cache to request - * @return A pointer to the cache held by the full client or NULL - * if there was no cache in the first place - */ -ethash_cache_t* ethash_full_get_cache(ethash_full_t full); -/** - * Move the memory ownership of the cache somewhere else - * - * @param full The full client whose cache's memory ownership to acquire. - * After this function concludes it will no longer have a cache. - * @return A pointer to the moved cache or NULL if there was no cache in the first place - */ -ethash_cache_t* ethash_full_acquire_cache(ethash_full_t full); void ethash_get_seedhash(ethash_h256_t *seedhash, const uint32_t block_number); diff --git a/internal.c b/internal.c index 6f9afec3c..9a75a12fd 100644 --- a/internal.c +++ b/internal.c @@ -41,13 +41,13 @@ #include "sha3.h" #endif // WITH_CRYPTOPP -uint64_t ethash_get_datasize(uint32_t const block_number) +uint64_t ethash_get_datasize(uint64_t const block_number) { assert(block_number / ETHASH_EPOCH_LENGTH < 2048); return dag_sizes[block_number / ETHASH_EPOCH_LENGTH]; } -uint64_t ethash_get_cachesize(uint32_t const block_number) +uint64_t ethash_get_cachesize(uint64_t const block_number) { assert(block_number / ETHASH_EPOCH_LENGTH < 2048); return cache_sizes[block_number / ETHASH_EPOCH_LENGTH]; @@ -389,8 +389,6 @@ ethash_full_t ethash_full_new( if (!ret) { return NULL; } - - ret->cache = (ethash_cache_t*)cache; ret->file_size = (size_t)full_size; switch (ethash_io_prepare(dirname, *seed_hash, &f, (size_t)full_size)) { case ETHASH_IO_FAIL: @@ -438,9 +436,6 @@ fail_free_full: void ethash_full_delete(ethash_full_t full) { - if (full->cache) { - ethash_cache_delete(full->cache); - } // could check that munmap(..) == 0 but even if it did not can't really do anything here munmap(full->data, full->file_size); if (full->file) { @@ -472,18 +467,6 @@ void *ethash_full_data(ethash_full_t full) return full->data; } -ethash_cache_t* ethash_full_get_cache(ethash_full_t full) -{ - return full->cache; -} - -ethash_cache_t* ethash_full_acquire_cache(ethash_full_t full) -{ - ethash_cache_t* ret = full->cache; - full->cache = 0; - return ret; -} - /** * ========================= * = DEPRECATED API = diff --git a/internal.h b/internal.h index fdfa2f961..b5fcf71fe 100644 --- a/internal.h +++ b/internal.h @@ -38,7 +38,6 @@ struct ethash_light { struct ethash_full { FILE* file; uint64_t file_size; - ethash_cache_t* cache; node* data; ethash_callback_t callback; };