Browse Source

ethash_full should not keep cache_size

- plus block number is a uint64_t not uint32_t
cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
2f77c792a8
  1. 20
      ethash.h
  2. 21
      internal.c
  3. 1
      internal.h

20
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);

21
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 =

1
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;
};

Loading…
Cancel
Save