You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.0 KiB
84 lines
2.0 KiB
10 years ago
|
#pragma once
|
||
|
#include "compiler.h"
|
||
|
#include "endian.h"
|
||
|
#include "ethash.h"
|
||
10 years ago
|
#include <stdio.h>
|
||
10 years ago
|
|
||
10 years ago
|
#define ENABLE_SSE 0
|
||
10 years ago
|
|
||
|
#if defined(_M_X64) && ENABLE_SSE
|
||
|
#include <smmintrin.h>
|
||
|
#endif
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
// compile time settings
|
||
|
#define NODE_WORDS (64/4)
|
||
10 years ago
|
#define MIX_WORDS (ETHASH_MIX_BYTES/4)
|
||
10 years ago
|
#define MIX_NODES (MIX_WORDS / NODE_WORDS)
|
||
|
#include <stdint.h>
|
||
|
|
||
|
typedef union node {
|
||
10 years ago
|
uint8_t bytes[NODE_WORDS * 4];
|
||
|
uint32_t words[NODE_WORDS];
|
||
|
uint64_t double_words[NODE_WORDS / 2];
|
||
10 years ago
|
|
||
|
#if defined(_M_X64) && ENABLE_SSE
|
||
|
__m128i xmm[NODE_WORDS/4];
|
||
|
#endif
|
||
|
|
||
|
} node;
|
||
|
|
||
10 years ago
|
static inline void ethash_h256_reset(ethash_h256_t* hash)
|
||
|
{
|
||
|
memset(hash, 0, 32);
|
||
|
}
|
||
|
|
||
10 years ago
|
struct ethash_light {
|
||
10 years ago
|
void* cache;
|
||
|
uint64_t cache_size;
|
||
|
uint64_t block_number;
|
||
10 years ago
|
};
|
||
|
|
||
10 years ago
|
/**
|
||
|
* Allocate and initialize a new ethash_light handler. Internal version
|
||
|
*
|
||
|
* @param cache_size The size of the cache in bytes
|
||
|
* @param seed Block seedhash to be used during the computation of the
|
||
|
* cache nodes
|
||
|
* @return Newly allocated ethash_light handler or NULL in case of
|
||
|
* ERRNOMEM or invalid parameters used for @ref ethash_compute_cache_nodes()
|
||
|
*/
|
||
|
ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t const* seed);
|
||
|
|
||
|
/**
|
||
|
* Calculate the light client data. Internal version.
|
||
|
*
|
||
|
* @param light The light client handler
|
||
|
* @param full_size The size of the full data in bytes.
|
||
|
* @param header_hash The header hash to pack into the mix
|
||
|
* @param nonce The nonce to pack into the mix
|
||
10 years ago
|
* @return The resulting hash.
|
||
10 years ago
|
*/
|
||
10 years ago
|
ethash_return_value_t ethash_light_compute_internal(
|
||
10 years ago
|
ethash_light_t light,
|
||
|
uint64_t full_size,
|
||
10 years ago
|
ethash_h256_t const header_hash,
|
||
10 years ago
|
uint64_t nonce
|
||
10 years ago
|
);
|
||
|
|
||
10 years ago
|
void ethash_calculate_dag_item(
|
||
|
node* const ret,
|
||
10 years ago
|
uint32_t node_index,
|
||
10 years ago
|
ethash_light_t const cache
|
||
10 years ago
|
);
|
||
|
|
||
10 years ago
|
uint64_t ethash_get_datasize(uint64_t const block_number);
|
||
|
uint64_t ethash_get_cachesize(uint64_t const block_number);
|
||
|
|
||
10 years ago
|
#ifdef __cplusplus
|
||
|
}
|
||
10 years ago
|
#endif
|