/** * ========================= * = DEPRECATED API = * ========================= * * Kept for backwards compatibility with whoever still uses it. Please consider * switching to the new API (look above) */ void ethash_mkcache(ethash_cache *cache, ethash_params const *params, ethash_h256_t const* seed) { node *nodes = (node*) cache->mem; ethash_compute_cache_nodes(nodes, params, seed); }
ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t const* seed) { struct ethash_light *ret; ret = calloc(sizeof(*ret), 1); if (!ret) { return NULL; } ret->cache = malloc((size_t)cache_size); if (!ret->cache) { goto fail_free_light; } node* nodes = (node*)ret->cache; if (!ethash_compute_cache_nodes(nodes, cache_size, seed)) { goto fail_free_cache_mem; } ret->cache_size = cache_size; return ret; fail_free_cache_mem: free(ret->cache); fail_free_light: free(ret); return NULL; }
ethash_cache *ethash_cache_new(ethash_params const *params, ethash_h256_t const *seed) { ethash_cache *ret; ret = malloc(sizeof(*ret)); if (!ret) { return NULL; } ret->mem = malloc((size_t)params->cache_size); if (!ret->mem) { goto fail_free_cache; } node *nodes = (node*)ret->mem; if (!ethash_compute_cache_nodes(nodes, params, seed)) { goto fail_free_cache_mem; } return ret; fail_free_cache_mem: free(ret->mem); fail_free_cache: free(ret); return NULL; }