Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a9d6846f
Commit
a9d6846f
authored
Jun 16, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ethash Godep
parent
8f372c86
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
76 additions
and
13958 deletions
+76
-13958
Godeps.json
Godeps/Godeps.json
+2
-2
CMakeLists.txt
.../_workspace/src/github.com/ethereum/ethash/CMakeLists.txt
+0
-7
ethash.go
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+7
-0
CMakeLists.txt
...ithub.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
+0
-47
bin2h.cmake
...c/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake
+0
-86
cl.hpp
...ce/src/github.com/ethereum/ethash/src/libethash-cl/cl.hpp
+0
-12906
ethash_cl_miner.cpp
....com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
+0
-384
ethash_cl_miner.h
...ub.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
+0
-57
ethash_cl_miner_kernel.cl
...thereum/ethash/src/libethash-cl/ethash_cl_miner_kernel.cl
+0
-460
endian.h
...ace/src/github.com/ethereum/ethash/src/libethash/endian.h
+3
-0
internal.c
...e/src/github.com/ethereum/ethash/src/libethash/internal.c
+12
-1
io.c
...rkspace/src/github.com/ethereum/ethash/src/libethash/io.c
+19
-2
io.h
...rkspace/src/github.com/ethereum/ethash/src/libethash/io.h
+17
-0
io_posix.c
...e/src/github.com/ethereum/ethash/src/libethash/io_posix.c
+9
-0
io_win32.c
...e/src/github.com/ethereum/ethash/src/libethash/io_win32.c
+2
-2
test.cpp
..._workspace/src/github.com/ethereum/ethash/test/c/test.cpp
+5
-4
No files found.
Godeps/Godeps.json
View file @
a9d6846f
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
},
},
{
{
"ImportPath"
:
"github.com/ethereum/ethash"
,
"ImportPath"
:
"github.com/ethereum/ethash"
,
"Comment"
:
"v23.1-2
06-gf0e6321
"
,
"Comment"
:
"v23.1-2
22-g5cfdcba
"
,
"Rev"
:
"
f0e63218b721dc2f696920a92d5de1f6364e9bf
7"
"Rev"
:
"
5cfdcba92e634db228d1ddb140e3b7a3c4b3817
7"
},
},
{
{
"ImportPath"
:
"github.com/howeyc/fsnotify"
,
"ImportPath"
:
"github.com/howeyc/fsnotify"
,
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt
View file @
a9d6846f
...
@@ -9,13 +9,6 @@ if (WIN32 AND WANT_CRYPTOPP)
...
@@ -9,13 +9,6 @@ if (WIN32 AND WANT_CRYPTOPP)
endif
()
endif
()
add_subdirectory
(
src/libethash
)
add_subdirectory
(
src/libethash
)
# bin2h.cmake doesn't work
if
(
NOT OpenCL_FOUND
)
find_package
(
OpenCL
)
endif
()
if
(
OpenCL_FOUND
)
add_subdirectory
(
src/libethash-cl
)
endif
()
add_subdirectory
(
src/benchmark EXCLUDE_FROM_ALL
)
add_subdirectory
(
src/benchmark EXCLUDE_FROM_ALL
)
add_subdirectory
(
test/c
)
add_subdirectory
(
test/c
)
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
View file @
a9d6846f
...
@@ -8,6 +8,7 @@ int ethashGoCallback_cgo(unsigned);
...
@@ -8,6 +8,7 @@ int ethashGoCallback_cgo(unsigned);
import
"C"
import
"C"
import
(
import
(
"bytes"
"errors"
"errors"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
...
@@ -119,6 +120,12 @@ func (l *Light) Verify(block pow.Block) bool {
...
@@ -119,6 +120,12 @@ func (l *Light) Verify(block pow.Block) bool {
if
!
ret
.
success
{
if
!
ret
.
success
{
return
false
return
false
}
}
// avoid mixdigest malleability as it's not included in a block's "hashNononce"
if
!
bytes
.
Equal
(
block
.
MixDigest
()
.
Bytes
(),
C
.
GoBytes
(
unsafe
.
Pointer
(
&
ret
.
mix_hash
),
C
.
int
(
32
)))
{
return
false
}
// Make sure cache is live until after the C call.
// Make sure cache is live until after the C call.
// This is important because a GC might happen and execute
// This is important because a GC might happen and execute
// the finalizer before the call completes.
// the finalizer before the call completes.
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
deleted
100644 → 0
View file @
8f372c86
cmake_minimum_required
(
VERSION 2.8
)
set
(
LIBRARY ethash-cl
)
set
(
CMAKE_BUILD_TYPE Release
)
include
(
bin2h.cmake
)
bin2h
(
SOURCE_FILE ethash_cl_miner_kernel.cl
VARIABLE_NAME ethash_cl_miner_kernel
HEADER_FILE
${
CMAKE_CURRENT_BINARY_DIR
}
/ethash_cl_miner_kernel.h
)
if
(
NOT MSVC
)
# Initialize CXXFLAGS for c++11
set
(
CMAKE_CXX_FLAGS
"-Wall -std=c++11"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
set
(
CMAKE_CXX_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O2 -g"
)
# Compiler-specific C++11 activation.
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"GNU"
)
execute_process
(
COMMAND
${
CMAKE_CXX_COMPILER
}
-dumpversion OUTPUT_VARIABLE GCC_VERSION
)
if
(
NOT
(
GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7
))
message
(
FATAL_ERROR
"
${
PROJECT_NAME
}
requires g++ 4.7 or greater."
)
endif
()
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-stdlib=libc++"
)
else
()
message
(
FATAL_ERROR
"Your C++ compiler does not support C++11."
)
endif
()
endif
()
set
(
OpenCL_FOUND TRUE
)
set
(
OpenCL_INCLUDE_DIRS /usr/include/CL
)
set
(
OpenCL_LIBRARIES -lOpenCL
)
if
(
NOT OpenCL_FOUND
)
find_package
(
OpenCL
)
endif
()
if
(
OpenCL_FOUND
)
set
(
CMAKE_CXX_FLAGS
"-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -Werror -pedantic -fPIC
${
CMAKE_CXX_FLAGS
}
"
)
include_directories
(
${
OpenCL_INCLUDE_DIRS
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
include_directories
(
..
)
add_library
(
${
LIBRARY
}
ethash_cl_miner.cpp ethash_cl_miner.h cl.hpp
)
TARGET_LINK_LIBRARIES
(
${
LIBRARY
}
${
OpenCL_LIBRARIES
}
ethash
)
endif
()
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake
deleted
100644 → 0
View file @
8f372c86
# https://gist.github.com/sivachandran/3a0de157dccef822a230
include
(
CMakeParseArguments
)
# Function to wrap a given string into multiple lines at the given column position.
# Parameters:
# VARIABLE - The name of the CMake variable holding the string.
# AT_COLUMN - The column position at which string will be wrapped.
function
(
WRAP_STRING
)
set
(
oneValueArgs VARIABLE AT_COLUMN
)
cmake_parse_arguments
(
WRAP_STRING
"
${
options
}
"
"
${
oneValueArgs
}
"
""
${
ARGN
}
)
string
(
LENGTH
${${
WRAP_STRING_VARIABLE
}}
stringLength
)
math
(
EXPR offset
"0"
)
while
(
stringLength GREATER 0
)
if
(
stringLength GREATER
${
WRAP_STRING_AT_COLUMN
}
)
math
(
EXPR length
"
${
WRAP_STRING_AT_COLUMN
}
"
)
else
()
math
(
EXPR length
"
${
stringLength
}
"
)
endif
()
string
(
SUBSTRING
${${
WRAP_STRING_VARIABLE
}}
${
offset
}
${
length
}
line
)
set
(
lines
"
${
lines
}
\n
${
line
}
"
)
math
(
EXPR stringLength
"
${
stringLength
}
-
${
length
}
"
)
math
(
EXPR offset
"
${
offset
}
+
${
length
}
"
)
endwhile
()
set
(
${
WRAP_STRING_VARIABLE
}
"
${
lines
}
"
PARENT_SCOPE
)
endfunction
()
# Function to embed contents of a file as byte array in C/C++ header file(.h). The header file
# will contain a byte array and integer variable holding the size of the array.
# Parameters
# SOURCE_FILE - The path of source file whose contents will be embedded in the header file.
# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append
# to this name and will be used a variable name for size variable.
# HEADER_FILE - The path of header file.
# APPEND - If specified appends to the header file instead of overwriting it
# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be
# useful if the source file is a text file and we want to use the file contents
# as string. But the size variable holds size of the byte array without this
# null byte.
# Usage:
# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG")
function
(
BIN2H
)
set
(
options APPEND NULL_TERMINATE
)
set
(
oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE
)
cmake_parse_arguments
(
BIN2H
"
${
options
}
"
"
${
oneValueArgs
}
"
""
${
ARGN
}
)
# reads source file contents as hex string
file
(
READ
${
BIN2H_SOURCE_FILE
}
hexString HEX
)
string
(
LENGTH
${
hexString
}
hexStringLength
)
# appends null byte if asked
if
(
BIN2H_NULL_TERMINATE
)
set
(
hexString
"
${
hexString
}
00"
)
endif
()
# wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line)
wrap_string
(
VARIABLE hexString AT_COLUMN 32
)
math
(
EXPR arraySize
"
${
hexStringLength
}
/ 2"
)
# adds '0x' prefix and comma suffix before and after every byte respectively
string
(
REGEX REPLACE
"([0-9a-f][0-9a-f])"
"0x
\\
1, "
arrayValues
${
hexString
}
)
# removes trailing comma
string
(
REGEX REPLACE
", $"
""
arrayValues
${
arrayValues
}
)
# converts the variable name into proper C identifier
IF
(
${
CMAKE_VERSION
}
GREATER 2.8.10
)
# fix for legacy cmake
string
(
MAKE_C_IDENTIFIER
"
${
BIN2H_VARIABLE_NAME
}
"
BIN2H_VARIABLE_NAME
)
ENDIF
()
string
(
TOUPPER
"
${
BIN2H_VARIABLE_NAME
}
"
BIN2H_VARIABLE_NAME
)
# declares byte array and the length variables
set
(
arrayDefinition
"const unsigned char
${
BIN2H_VARIABLE_NAME
}
[] = {
${
arrayValues
}
};"
)
set
(
arraySizeDefinition
"const size_t
${
BIN2H_VARIABLE_NAME
}
_SIZE =
${
arraySize
}
;"
)
set
(
declarations
"
${
arrayDefinition
}
\n\n
${
arraySizeDefinition
}
\n\n
"
)
if
(
BIN2H_APPEND
)
file
(
APPEND
${
BIN2H_HEADER_FILE
}
"
${
declarations
}
"
)
else
()
file
(
WRITE
${
BIN2H_HEADER_FILE
}
"
${
declarations
}
"
)
endif
()
endfunction
()
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/cl.hpp
deleted
100644 → 0
View file @
8f372c86
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
deleted
100644 → 0
View file @
8f372c86
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
deleted
100644 → 0
View file @
8f372c86
#pragma once
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#include "cl.hpp"
#pragma clang diagnostic pop
#else
#include "cl.hpp"
#endif
#include <time.h>
#include <functional>
#include <libethash/ethash.h>
class
ethash_cl_miner
{
public
:
struct
search_hook
{
virtual
~
search_hook
();
// always a virtual destructor for a class with virtuals.
// reports progress, return true to abort
virtual
bool
found
(
uint64_t
const
*
nonces
,
uint32_t
count
)
=
0
;
virtual
bool
searched
(
uint64_t
start_nonce
,
uint32_t
count
)
=
0
;
};
public
:
ethash_cl_miner
();
bool
init
(
uint64_t
block_number
,
std
::
function
<
void
(
void
*
)
>
_fillDAG
,
unsigned
workgroup_size
=
64
,
unsigned
_platformId
=
0
,
unsigned
_deviceId
=
0
);
static
std
::
string
platform_info
(
unsigned
_platformId
=
0
,
unsigned
_deviceId
=
0
);
static
unsigned
get_num_devices
(
unsigned
_platformId
=
0
);
void
finish
();
void
hash
(
uint8_t
*
ret
,
uint8_t
const
*
header
,
uint64_t
nonce
,
unsigned
count
);
void
search
(
uint8_t
const
*
header
,
uint64_t
target
,
search_hook
&
hook
);
private
:
enum
{
c_max_search_results
=
63
,
c_num_buffers
=
2
,
c_hash_batch_size
=
1024
,
c_search_batch_size
=
1024
*
256
};
uint64_t
m_fullSize
;
cl
::
Context
m_context
;
cl
::
CommandQueue
m_queue
;
cl
::
Kernel
m_hash_kernel
;
cl
::
Kernel
m_search_kernel
;
cl
::
Buffer
m_dag
;
cl
::
Buffer
m_header
;
cl
::
Buffer
m_hash_buf
[
c_num_buffers
];
cl
::
Buffer
m_search_buf
[
c_num_buffers
];
unsigned
m_workgroup_size
;
bool
m_opencl_1_1
;
};
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner_kernel.cl
deleted
100644 → 0
View file @
8f372c86
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
View file @
a9d6846f
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
#include <libkern/OSByteOrder.h>
#include <libkern/OSByteOrder.h>
#define ethash_swap_u32(input_) OSSwapInt32(input_)
#define ethash_swap_u32(input_) OSSwapInt32(input_)
#define ethash_swap_u64(input_) OSSwapInt64(input_)
#define ethash_swap_u64(input_) OSSwapInt64(input_)
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
#define ethash_swap_u32(input_) bswap32(input_)
#define ethash_swap_u64(input_) bswap64(input_)
#else // posix
#else // posix
#include <byteswap.h>
#include <byteswap.h>
#define ethash_swap_u32(input_) __bswap_32(input_)
#define ethash_swap_u32(input_) __bswap_32(input_)
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
View file @
a9d6846f
...
@@ -364,6 +364,7 @@ static bool ethash_mmap(struct ethash_full* ret, FILE* f)
...
@@ -364,6 +364,7 @@ static bool ethash_mmap(struct ethash_full* ret, FILE* f)
{
{
int
fd
;
int
fd
;
char
*
mmapped_data
;
char
*
mmapped_data
;
errno
=
0
;
ret
->
file
=
f
;
ret
->
file
=
f
;
if
((
fd
=
ethash_fileno
(
ret
->
file
))
==
-
1
)
{
if
((
fd
=
ethash_fileno
(
ret
->
file
))
==
-
1
)
{
return
false
;
return
false
;
...
@@ -400,38 +401,48 @@ ethash_full_t ethash_full_new_internal(
...
@@ -400,38 +401,48 @@ ethash_full_t ethash_full_new_internal(
ret
->
file_size
=
(
size_t
)
full_size
;
ret
->
file_size
=
(
size_t
)
full_size
;
switch
(
ethash_io_prepare
(
dirname
,
seed_hash
,
&
f
,
(
size_t
)
full_size
,
false
))
{
switch
(
ethash_io_prepare
(
dirname
,
seed_hash
,
&
f
,
(
size_t
)
full_size
,
false
))
{
case
ETHASH_IO_FAIL
:
case
ETHASH_IO_FAIL
:
// ethash_io_prepare will do all ETHASH_CRITICAL() logging in fail case
goto
fail_free_full
;
goto
fail_free_full
;
case
ETHASH_IO_MEMO_MATCH
:
case
ETHASH_IO_MEMO_MATCH
:
if
(
!
ethash_mmap
(
ret
,
f
))
{
if
(
!
ethash_mmap
(
ret
,
f
))
{
ETHASH_CRITICAL
(
"mmap failure()"
);
goto
fail_close_file
;
goto
fail_close_file
;
}
}
return
ret
;
return
ret
;
case
ETHASH_IO_MEMO_SIZE_MISMATCH
:
case
ETHASH_IO_MEMO_SIZE_MISMATCH
:
// if a DAG of same filename but unexpected size is found, silently force new file creation
// if a DAG of same filename but unexpected size is found, silently force new file creation
if
(
ethash_io_prepare
(
dirname
,
seed_hash
,
&
f
,
(
size_t
)
full_size
,
true
)
!=
ETHASH_IO_MEMO_MISMATCH
)
{
if
(
ethash_io_prepare
(
dirname
,
seed_hash
,
&
f
,
(
size_t
)
full_size
,
true
)
!=
ETHASH_IO_MEMO_MISMATCH
)
{
ETHASH_CRITICAL
(
"Could not recreate DAG file after finding existing DAG with unexpected size."
);
goto
fail_free_full
;
goto
fail_free_full
;
}
}
// fallthrough to the mismatch case here, DO NOT go through match
// fallthrough to the mismatch case here, DO NOT go through match
case
ETHASH_IO_MEMO_MISMATCH
:
case
ETHASH_IO_MEMO_MISMATCH
:
if
(
!
ethash_mmap
(
ret
,
f
))
{
if
(
!
ethash_mmap
(
ret
,
f
))
{
ETHASH_CRITICAL
(
"mmap failure()"
);
goto
fail_close_file
;
goto
fail_close_file
;
}
}
break
;
break
;
}
}
if
(
!
ethash_compute_full_data
(
ret
->
data
,
full_size
,
light
,
callback
))
{
if
(
!
ethash_compute_full_data
(
ret
->
data
,
full_size
,
light
,
callback
))
{
ETHASH_CRITICAL
(
"Failure at computing DAG data."
);
goto
fail_free_full_data
;
goto
fail_free_full_data
;
}
}
// after the DAG has been filled then we finalize it by writting the magic number at the beginning
// after the DAG has been filled then we finalize it by writting the magic number at the beginning
if
(
fseek
(
f
,
0
,
SEEK_SET
)
!=
0
)
{
if
(
fseek
(
f
,
0
,
SEEK_SET
)
!=
0
)
{
ETHASH_CRITICAL
(
"Could not seek to DAG file start to write magic number."
);
goto
fail_free_full_data
;
goto
fail_free_full_data
;
}
}
uint64_t
const
magic_num
=
ETHASH_DAG_MAGIC_NUM
;
uint64_t
const
magic_num
=
ETHASH_DAG_MAGIC_NUM
;
if
(
fwrite
(
&
magic_num
,
ETHASH_DAG_MAGIC_NUM_SIZE
,
1
,
f
)
!=
1
)
{
if
(
fwrite
(
&
magic_num
,
ETHASH_DAG_MAGIC_NUM_SIZE
,
1
,
f
)
!=
1
)
{
ETHASH_CRITICAL
(
"Could not write magic number to DAG's beginning."
);
goto
fail_free_full_data
;
}
if
(
fflush
(
f
)
!=
0
)
{
// make sure the magic number IS there
ETHASH_CRITICAL
(
"Could not flush memory mapped data to DAG file. Insufficient space?"
);
goto
fail_free_full_data
;
goto
fail_free_full_data
;
}
}
fflush
(
f
);
// make sure the magic number IS there
return
ret
;
return
ret
;
fail_free_full_data:
fail_free_full_data:
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.c
View file @
a9d6846f
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "io.h"
#include "io.h"
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
enum
ethash_io_rc
ethash_io_prepare
(
enum
ethash_io_rc
ethash_io_prepare
(
char
const
*
dirname
,
char
const
*
dirname
,
...
@@ -32,15 +33,19 @@ enum ethash_io_rc ethash_io_prepare(
...
@@ -32,15 +33,19 @@ enum ethash_io_rc ethash_io_prepare(
{
{
char
mutable_name
[
DAG_MUTABLE_NAME_MAX_SIZE
];
char
mutable_name
[
DAG_MUTABLE_NAME_MAX_SIZE
];
enum
ethash_io_rc
ret
=
ETHASH_IO_FAIL
;
enum
ethash_io_rc
ret
=
ETHASH_IO_FAIL
;
// reset errno before io calls
errno
=
0
;
// assert directory exists
// assert directory exists
if
(
!
ethash_mkdir
(
dirname
))
{
if
(
!
ethash_mkdir
(
dirname
))
{
ETHASH_CRITICAL
(
"Could not create the ethash directory"
);
goto
end
;
goto
end
;
}
}
ethash_io_mutable_name
(
ETHASH_REVISION
,
&
seedhash
,
mutable_name
);
ethash_io_mutable_name
(
ETHASH_REVISION
,
&
seedhash
,
mutable_name
);
char
*
tmpfile
=
ethash_io_create_filename
(
dirname
,
mutable_name
,
strlen
(
mutable_name
));
char
*
tmpfile
=
ethash_io_create_filename
(
dirname
,
mutable_name
,
strlen
(
mutable_name
));
if
(
!
tmpfile
)
{
if
(
!
tmpfile
)
{
ETHASH_CRITICAL
(
"Could not create the full DAG pathname"
);
goto
end
;
goto
end
;
}
}
...
@@ -52,6 +57,7 @@ enum ethash_io_rc ethash_io_prepare(
...
@@ -52,6 +57,7 @@ enum ethash_io_rc ethash_io_prepare(
size_t
found_size
;
size_t
found_size
;
if
(
!
ethash_file_size
(
f
,
&
found_size
))
{
if
(
!
ethash_file_size
(
f
,
&
found_size
))
{
fclose
(
f
);
fclose
(
f
);
ETHASH_CRITICAL
(
"Could not query size of DAG file:
\"
%s
\"
"
,
tmpfile
);
goto
free_memo
;
goto
free_memo
;
}
}
if
(
file_size
!=
found_size
-
ETHASH_DAG_MAGIC_NUM_SIZE
)
{
if
(
file_size
!=
found_size
-
ETHASH_DAG_MAGIC_NUM_SIZE
)
{
...
@@ -64,6 +70,7 @@ enum ethash_io_rc ethash_io_prepare(
...
@@ -64,6 +70,7 @@ enum ethash_io_rc ethash_io_prepare(
if
(
fread
(
&
magic_num
,
ETHASH_DAG_MAGIC_NUM_SIZE
,
1
,
f
)
!=
1
)
{
if
(
fread
(
&
magic_num
,
ETHASH_DAG_MAGIC_NUM_SIZE
,
1
,
f
)
!=
1
)
{
// I/O error
// I/O error
fclose
(
f
);
fclose
(
f
);
ETHASH_CRITICAL
(
"Could not read from DAG file:
\"
%s
\"
"
,
tmpfile
);
ret
=
ETHASH_IO_MEMO_SIZE_MISMATCH
;
ret
=
ETHASH_IO_MEMO_SIZE_MISMATCH
;
goto
free_memo
;
goto
free_memo
;
}
}
...
@@ -80,15 +87,25 @@ enum ethash_io_rc ethash_io_prepare(
...
@@ -80,15 +87,25 @@ enum ethash_io_rc ethash_io_prepare(
// file does not exist, will need to be created
// file does not exist, will need to be created
f
=
ethash_fopen
(
tmpfile
,
"wb+"
);
f
=
ethash_fopen
(
tmpfile
,
"wb+"
);
if
(
!
f
)
{
if
(
!
f
)
{
ETHASH_CRITICAL
(
"Could not create DAG file:
\"
%s
\"
"
,
tmpfile
);
goto
free_memo
;
goto
free_memo
;
}
}
// make sure it's of the proper size
// make sure it's of the proper size
if
(
fseek
(
f
,
(
long
int
)(
file_size
+
ETHASH_DAG_MAGIC_NUM_SIZE
-
1
),
SEEK_SET
)
!=
0
)
{
if
(
fseek
(
f
,
(
long
int
)(
file_size
+
ETHASH_DAG_MAGIC_NUM_SIZE
-
1
),
SEEK_SET
)
!=
0
)
{
fclose
(
f
);
fclose
(
f
);
ETHASH_CRITICAL
(
"Could not seek to the end of DAG file:
\"
%s
\"
. Insufficient space?"
,
tmpfile
);
goto
free_memo
;
}
if
(
fputc
(
'\n'
,
f
)
==
EOF
)
{
fclose
(
f
);
ETHASH_CRITICAL
(
"Could not write in the end of DAG file:
\"
%s
\"
. Insufficient space?"
,
tmpfile
);
goto
free_memo
;
}
if
(
fflush
(
f
)
!=
0
)
{
fclose
(
f
);
ETHASH_CRITICAL
(
"Could not flush at end of DAG file:
\"
%s
\"
. Insufficient space?"
,
tmpfile
);
goto
free_memo
;
goto
free_memo
;
}
}
fputc
(
'\n'
,
f
);
fflush
(
f
);
ret
=
ETHASH_IO_MEMO_MISMATCH
;
ret
=
ETHASH_IO_MEMO_MISMATCH
;
goto
set_file
;
goto
set_file
;
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.h
View file @
a9d6846f
...
@@ -54,6 +54,23 @@ enum ethash_io_rc {
...
@@ -54,6 +54,23 @@ enum ethash_io_rc {
#define snprintf(...) sprintf_s(__VA_ARGS__)
#define snprintf(...) sprintf_s(__VA_ARGS__)
#endif
#endif
/**
* Logs a critical error in important parts of ethash. Should mostly help
* figure out what kind of problem (I/O, memory e.t.c.) causes a NULL
* ethash_full_t
*/
#ifdef ETHASH_PRINT_CRITICAL_OUTPUT
#define ETHASH_CRITICAL(...) \
do \
{ \
printf("ETHASH CRITICAL ERROR: "__VA_ARGS__); \
printf("\n"); \
fflush(stdout); \
} while (0)
#else
#define ETHASH_CRITICAL(...)
#endif
/**
/**
* Prepares io for ethash
* Prepares io for ethash
*
*
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c
View file @
a9d6846f
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
#include <libgen.h>
#include <libgen.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
FILE
*
ethash_fopen
(
char
const
*
file_name
,
char
const
*
mode
)
FILE
*
ethash_fopen
(
char
const
*
file_name
,
char
const
*
mode
)
{
{
...
@@ -89,6 +91,13 @@ bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
...
@@ -89,6 +91,13 @@ bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
static
const
char
dir_suffix
[]
=
".ethash/"
;
static
const
char
dir_suffix
[]
=
".ethash/"
;
strbuf
[
0
]
=
'\0'
;
strbuf
[
0
]
=
'\0'
;
char
*
home_dir
=
getenv
(
"HOME"
);
char
*
home_dir
=
getenv
(
"HOME"
);
if
(
!
home_dir
||
strlen
(
home_dir
)
==
0
)
{
struct
passwd
*
pwd
=
getpwuid
(
getuid
());
if
(
pwd
)
home_dir
=
pwd
->
pw_dir
;
}
size_t
len
=
strlen
(
home_dir
);
size_t
len
=
strlen
(
home_dir
);
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
home_dir
,
len
))
{
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
home_dir
,
len
))
{
return
false
;
return
false
;
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_win32.c
View file @
a9d6846f
...
@@ -87,9 +87,9 @@ bool ethash_file_size(FILE* f, size_t* ret_size)
...
@@ -87,9 +87,9 @@ bool ethash_file_size(FILE* f, size_t* ret_size)
bool
ethash_get_default_dirname
(
char
*
strbuf
,
size_t
buffsize
)
bool
ethash_get_default_dirname
(
char
*
strbuf
,
size_t
buffsize
)
{
{
static
const
char
dir_suffix
[]
=
"
Appdata
\\
Ethash
\\
"
;
static
const
char
dir_suffix
[]
=
"Ethash
\\
"
;
strbuf
[
0
]
=
'\0'
;
strbuf
[
0
]
=
'\0'
;
if
(
!
SUCCEEDED
(
SHGetFolderPath
W
(
NULL
,
CSIDL_PROFILE
,
NULL
,
0
,
(
W
CHAR
*
)
strbuf
)))
{
if
(
!
SUCCEEDED
(
SHGetFolderPath
A
(
NULL
,
CSIDL_LOCAL_APPDATA
,
NULL
,
0
,
(
CHAR
*
)
strbuf
)))
{
return
false
;
return
false
;
}
}
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
"
\\
"
,
1
))
{
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
"
\\
"
,
1
))
{
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
View file @
a9d6846f
...
@@ -292,12 +292,13 @@ BOOST_AUTO_TEST_CASE(test_ethash_io_memo_file_size_mismatch) {
...
@@ -292,12 +292,13 @@ BOOST_AUTO_TEST_CASE(test_ethash_io_memo_file_size_mismatch) {
BOOST_AUTO_TEST_CASE
(
test_ethash_get_default_dirname
)
{
BOOST_AUTO_TEST_CASE
(
test_ethash_get_default_dirname
)
{
char
result
[
256
];
char
result
[
256
];
// this is really not an easy thing to test for in a unit test, so yeah it does look ugly
// this is really not an easy thing to test for in a unit test
// TODO: Improve this test ...
#ifdef _WIN32
#ifdef _WIN32
char
homedir
[
256
];
char
homedir
[
256
];
BOOST_REQUIRE
(
SUCCEEDED
(
SHGetFolderPath
W
(
NULL
,
CSIDL_PROFILE
,
NULL
,
0
,
(
W
CHAR
*
)
homedir
)));
BOOST_REQUIRE
(
SUCCEEDED
(
SHGetFolderPath
A
(
NULL
,
CSIDL_PROFILE
,
NULL
,
0
,
(
CHAR
*
)
homedir
)));
BOOST_REQUIRE
(
ethash_get_default_dirname
(
result
,
256
));
BOOST_REQUIRE
(
ethash_get_default_dirname
(
result
,
256
));
std
::
string
res
=
std
::
string
(
homedir
)
+
std
::
string
(
"
\\
App
data
\\
Ethash
\\
"
);
std
::
string
res
=
std
::
string
(
homedir
)
+
std
::
string
(
"
\\
App
Data
\\
Local
\\
Ethash
\\
"
);
#else
#else
char
*
homedir
=
getenv
(
"HOME"
);
char
*
homedir
=
getenv
(
"HOME"
);
BOOST_REQUIRE
(
ethash_get_default_dirname
(
result
,
256
));
BOOST_REQUIRE
(
ethash_get_default_dirname
(
result
,
256
));
...
@@ -305,7 +306,7 @@ BOOST_AUTO_TEST_CASE(test_ethash_get_default_dirname) {
...
@@ -305,7 +306,7 @@ BOOST_AUTO_TEST_CASE(test_ethash_get_default_dirname) {
#endif
#endif
BOOST_CHECK_MESSAGE
(
strcmp
(
res
.
c_str
(),
result
)
==
0
,
BOOST_CHECK_MESSAGE
(
strcmp
(
res
.
c_str
(),
result
)
==
0
,
"Expected
\"
"
+
res
+
"
\"
but got
\"
"
+
std
::
string
(
result
)
+
"
\"
"
"Expected
\"
"
+
res
+
"
\"
but got
\"
"
+
std
::
string
(
result
)
+
"
\"
"
);
);
}
}
BOOST_AUTO_TEST_CASE
(
light_and_full_client_checks
)
{
BOOST_AUTO_TEST_CASE
(
light_and_full_client_checks
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment