Browse Source

More const related style fixes

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
c70f3e5692
  1. 20
      ethash.h
  2. 20
      internal.c
  3. 4
      io.h
  4. 4
      io_posix.c
  5. 4
      io_win32.c

20
ethash.h

@ -87,11 +87,11 @@ typedef struct ethash_return_value {
ethash_h256_t mix_hash;
} ethash_return_value;
uint64_t ethash_get_datasize(const uint32_t block_number);
uint64_t ethash_get_cachesize(const uint32_t block_number);
uint64_t ethash_get_datasize(uint32_t const block_number);
uint64_t ethash_get_cachesize(uint32_t const block_number);
// initialize the parameters
static inline void ethash_params_init(ethash_params* params, const uint32_t block_number)
static inline void ethash_params_init(ethash_params* params, uint32_t const block_number)
{
params->full_size = ethash_get_datasize(block_number);
params->cache_size = ethash_get_cachesize(block_number);
@ -99,7 +99,7 @@ static inline void ethash_params_init(ethash_params* params, const uint32_t bloc
// LTODO: for consistency's sake maybe use ethash_cache_t?
typedef struct ethash_cache {
void *mem;
void* mem;
} ethash_cache;
/**
@ -151,7 +151,7 @@ bool ethash_light_compute(
ethash_light_t light,
ethash_params const* params,
const ethash_h256_t* header_hash,
const uint64_t nonce
uint64_t const nonce
);
/**
* Get a pointer to the cache object held by the light client
@ -216,8 +216,8 @@ bool ethash_full_compute(
ethash_return_value* ret,
ethash_full_t full,
ethash_params const* params,
const ethash_h256_t* header_hash,
const uint64_t nonce
ethash_h256_t const* header_hash,
uint64_t const nonce
);
/**
* Get a pointer to the cache object held by the full client
@ -256,7 +256,7 @@ static inline int ethash_check_difficulty(
int ethash_quick_check_difficulty(
ethash_h256_t const* header_hash,
const uint64_t nonce,
uint64_t const nonce,
ethash_h256_t const* mix_hash,
ethash_h256_t const* difficulty
);
@ -276,14 +276,14 @@ void ethash_full(
void const* full_mem,
ethash_params const* params,
ethash_h256_t const* header_hash,
const uint64_t nonce
uint64_t const nonce
);
void ethash_light(
ethash_return_value* ret,
ethash_cache const* cache,
ethash_params const* params,
ethash_h256_t const* header_hash,
const uint64_t nonce
uint64_t const nonce
);
/**
* Compute the memory data for a full node's memory

20
internal.c

@ -41,13 +41,13 @@
#include "sha3.h"
#endif // WITH_CRYPTOPP
uint64_t ethash_get_datasize(const uint32_t block_number)
uint64_t ethash_get_datasize(uint32_t const block_number)
{
assert(block_number / EPOCH_LENGTH < 2048);
return dag_sizes[block_number / EPOCH_LENGTH];
}
uint64_t ethash_get_cachesize(const uint32_t block_number)
uint64_t ethash_get_cachesize(uint32_t const block_number)
{
assert(block_number / EPOCH_LENGTH < 2048);
return cache_sizes[block_number / EPOCH_LENGTH];
@ -198,7 +198,7 @@ static bool ethash_hash(
ethash_cache const* cache,
ethash_params const* params,
ethash_h256_t const* header_hash,
const uint64_t nonce,
uint64_t const nonce,
ethash_callback_t callback
)
{
@ -286,7 +286,7 @@ static bool ethash_hash(
void ethash_quick_hash(
ethash_h256_t* return_hash,
ethash_h256_t const* header_hash,
const uint64_t nonce,
uint64_t const nonce,
ethash_h256_t const* mix_hash
)
{
@ -309,7 +309,7 @@ void ethash_get_seedhash(ethash_h256_t* seedhash, const uint32_t block_number)
int ethash_quick_check_difficulty(
ethash_h256_t const* header_hash,
const uint64_t nonce,
uint64_t const nonce,
ethash_h256_t const* mix_hash,
ethash_h256_t const* difficulty
)
@ -351,7 +351,7 @@ bool ethash_light_compute(
ethash_light_t light,
ethash_params const* params,
const ethash_h256_t* header_hash,
const uint64_t nonce
uint64_t const nonce
)
{
return ethash_hash(ret, NULL, light->cache, params, header_hash, nonce, NULL);
@ -449,8 +449,8 @@ bool ethash_full_compute(
ethash_return_value* ret,
ethash_full_t full,
ethash_params const* params,
const ethash_h256_t* header_hash,
const uint64_t nonce
ethash_h256_t const* header_hash,
uint64_t const nonce
)
{
return ethash_hash(ret,
@ -496,7 +496,7 @@ void ethash_full(
void const* full_mem,
ethash_params const* params,
ethash_h256_t const* header_hash,
const uint64_t nonce
uint64_t const nonce
)
{
ethash_hash(ret, (node const *) full_mem, NULL, params, header_hash, nonce, NULL);
@ -506,7 +506,7 @@ void ethash_light(
ethash_cache const* cache,
ethash_params const* params,
ethash_h256_t const* header_hash,
const uint64_t nonce
uint64_t const nonce
)
{
ethash_hash(ret, NULL, cache, params, header_hash, nonce, NULL);

4
io.h

@ -90,7 +90,7 @@ enum ethash_io_rc ethash_io_prepare(
* @param mode Opening mode. Check fopen()
* @return The FILE* or NULL in failure
*/
FILE* ethash_fopen(const char* file_name, const char* mode);
FILE* ethash_fopen(char const* file_name, char const* mode);
/**
* An strncat wrapper for no-warnings crossplatform strncat.
@ -108,7 +108,7 @@ FILE* ethash_fopen(const char* file_name, const char* mode);
* @return If all is well returns the dest buffer. If there is an
* error returns NULL
*/
char* ethash_strncat(char* dest, size_t dest_size, const char* src, size_t count);
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count);
/**
* A cross-platform mkdir wrapper to create a directory or assert it's there

4
io_posix.c

@ -27,12 +27,12 @@
#include <stdio.h>
#include <unistd.h>
FILE* ethash_fopen(const char* file_name, const char* mode)
FILE* ethash_fopen(char const* file_name, char const* mode)
{
return fopen(file_name, mode);
}
char* ethash_strncat(char* dest, size_t dest_size, const char* src, size_t count)
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count)
{
return strlen(dest) + count + 1 <= dest_size ? strncat(dest, src, count) : NULL;
}

4
io_win32.c

@ -26,13 +26,13 @@
#include <sys/stat.h>
#include <sys/types.h>
FILE* ethash_fopen(const char* file_name, const char* mode)
FILE* ethash_fopen(char const* file_name, char const* mode)
{
FILE* f;
return fopen_s(&f, file_name, mode) == 0 ? f : NULL;
}
char* ethash_strncat(char* dest, size_t dest_size, const char* src, size_t count)
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count)
{
return strncat_s(dest, dest_size, src, count) == 0 ? dest : NULL;
}

Loading…
Cancel
Save