Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
50659f4b
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
50659f4b
编写于
5月 05, 2015
作者:
G
Gustav Simonsson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update ethash Godeps files
上级
2e9ed6f7
变更
39
展开全部
隐藏空白更改
内联
并排
Showing
39 changed file
with
3369 addition
and
2353 deletion
+3369
-2353
Godeps/Godeps.json
Godeps/Godeps.json
+2
-2
Godeps/_workspace/src/github.com/ethereum/ethash/.travis.yml
Godeps/_workspace/src/github.com/ethereum/ethash/.travis.yml
+14
-5
Godeps/_workspace/src/github.com/ethereum/ethash/README.md
Godeps/_workspace/src/github.com/ethereum/ethash/README.md
+16
-1
Godeps/_workspace/src/github.com/ethereum/ethash/appveyor.yml
...ps/_workspace/src/github.com/ethereum/ethash/appveyor.yml
+43
-0
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+245
-331
Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
.../_workspace/src/github.com/ethereum/ethash/ethash_test.go
+176
-0
Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
+24
-0
Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
+30
-17
Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt
...c/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt
+23
-23
Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
...rc/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
+34
-29
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
...ithub.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
+1
-1
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
....com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
+99
-44
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
...ub.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
+19
-7
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner_kernel.cl
...thereum/ethash/src/libethash-cl/ethash_cl_miner_kernel.cl
+2
-3
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
...c/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
+2
-3
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h
...src/github.com/ethereum/ethash/src/libethash/data_sizes.h
+738
-738
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
...ace/src/github.com/ethereum/ethash/src/libethash/endian.h
+36
-38
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h
...ace/src/github.com/ethereum/ethash/src/libethash/ethash.h
+106
-109
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
...kspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
+4
-3
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
...e/src/github.com/ethereum/ethash/src/libethash/internal.c
+408
-222
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h
...e/src/github.com/ethereum/ethash/src/libethash/internal.h
+137
-12
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.c
...rkspace/src/github.com/ethereum/ethash/src/libethash/io.c
+71
-58
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.h
...rkspace/src/github.com/ethereum/ethash/src/libethash/io.h
+133
-64
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c
...e/src/github.com/ethereum/ethash/src/libethash/io_posix.c
+64
-38
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_win32.c
...e/src/github.com/ethereum/ethash/src/libethash/io_win32.c
+65
-38
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/mmap.h
...space/src/github.com/ethereum/ethash/src/libethash/mmap.h
+47
-0
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/mmap_win32.c
...src/github.com/ethereum/ethash/src/libethash/mmap_win32.c
+84
-0
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3.c
...space/src/github.com/ethereum/ethash/src/libethash/sha3.c
+97
-97
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3.h
...space/src/github.com/ethereum/ethash/src/libethash/sha3.h
+6
-6
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
...ithub.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
+8
-6
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h
.../github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h
+3
-4
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h
...space/src/github.com/ethereum/ethash/src/libethash/util.h
+1
-1
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util_win32.c
...src/github.com/ethereum/ethash/src/libethash/util_win32.c
+3
-6
Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c
...orkspace/src/github.com/ethereum/ethash/src/python/core.c
+39
-40
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/CMakeLists.txt
...pace/src/github.com/ethereum/ethash/test/c/CMakeLists.txt
+8
-5
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
..._workspace/src/github.com/ethereum/ethash/test/c/test.cpp
+563
-316
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh
.../_workspace/src/github.com/ethereum/ethash/test/c/test.sh
+13
-0
Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go
...ace/src/github.com/ethereum/ethash/test/go/ethash_test.go
+0
-82
Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
...ps/_workspace/src/github.com/ethereum/ethash/test/test.sh
+5
-4
未找到文件。
Godeps/Godeps.json
浏览文件 @
50659f4b
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
},
},
{
{
"ImportPath"
:
"github.com/ethereum/ethash"
,
"ImportPath"
:
"github.com/ethereum/ethash"
,
"Comment"
:
"v23.1-
82-g908aad3
"
,
"Comment"
:
"v23.1-
192-g4faa4cb
"
,
"Rev"
:
"
908aad345c9fbf3ab9bbb94031dc02d0d90df1b8
"
"Rev"
:
"
4faa4cb42ae7f0ea6b4aa2c90cb9170fdcbb915a
"
},
},
{
{
"ImportPath"
:
"github.com/howeyc/fsnotify"
,
"ImportPath"
:
"github.com/howeyc/fsnotify"
,
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/.travis.yml
浏览文件 @
50659f4b
# making our travis.yml play well with C++11 by obtaining g++4.8
language
:
go
# Taken from this file:
go
:
# https://github.com/beark/ftl/blob/master/.travis.yml
-
1.4.2
before_install
:
before_install
:
# for g++4.8 and C++11
-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
# Set up go-ethereum
-
sudo apt-get update -y -qq
-
sudo apt-get update -y -qq
-
sudo apt-get install -yqq libgmp3-dev
-
git clone --depth=10 https://github.com/ethereum/go-ethereum ${GOPATH}/src/github.com/ethereum/go-ethereum
# use canned dependencies from the go-ethereum repository
-
export GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace/
-
echo $GOPATH
install
:
install
:
# need to explicitly request version 1.48 since by default we get 1.46 which does not work with C++11
-
sudo apt-get install -qq --yes --force-yes g++-4.8
-
sudo apt-get install -qq --yes --force-yes g++-4.8
-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8
50
-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8
50
# need to explicitly request version 1.48 since by default we get 1.46 which does not work with C++11
-
sudo apt-get install -qq wget cmake bash libboost-test1.48-dev libboost-system1.48-dev libboost-filesystem1.48-dev nodejs python-pip python-dev valgrind
-
sudo apt-get install -qq wget cmake bash libboost-test1.48-dev libboost-system1.48-dev libboost-filesystem1.48-dev nodejs python-pip python-dev
-
sudo pip install virtualenv -q
-
sudo pip install virtualenv -q
script
:
"
./test/test.sh"
script
:
"
./test/test.sh"
Godeps/_workspace/src/github.com/ethereum/ethash/README.md
浏览文件 @
50659f4b
[
![Build Status
](
https://travis-ci.org/ethereum/ethash.svg?branch=master
)
](https://travis-ci.org/ethereum/ethash)
[
![Build Status
](
https://travis-ci.org/ethereum/ethash.svg?branch=master
)
](https://travis-ci.org/ethereum/ethash)
[
![Windows Build Status
](
https://ci.appveyor.com/api/projects/status/github/debris/ethash?branch=master&svg=true
)
](https://ci.appveyor.com/project/debris/ethash-nr37r/branch/master)
# Ethash
# Ethash
For details on this project, please see the Ethereum wiki:
For details on this project, please see the Ethereum wiki:
https://github.com/ethereum/wiki/wiki/Ethash
https://github.com/ethereum/wiki/wiki/Ethash
### Coding Style for C++ code:
Follow the same exact style as in
[
cpp-ethereum
](
https://github.com/ethereum/cpp-ethereum/blob/develop/CodingStandards.txt
)
### Coding Style for C code:
The main thing above all is code consistency.
-
Tabs for indentation. A tab is 4 spaces
-
Try to stick to the
[
K&R
](
http://en.wikipedia.org/wiki/Indent_style#K.26R_style
)
,
especially for the C code.
-
Keep the line lengths reasonable. No hard limit on 80 characters but don't go further
than 110. Some people work with multiple buffers next to each other.
Make them like you :)
Godeps/_workspace/src/github.com/ethereum/ethash/appveyor.yml
0 → 100644
浏览文件 @
50659f4b
version
:
1.0.0.{build}
environment
:
BOOST_ROOT
:
"
c:/projects/ethash/deps/boost"
branches
:
only
:
-
master
-
develop
os
:
Windows Server 2012 R2
clone_folder
:
c:\projects\ethash
#platform: Any CPU
#configuration: Debug
install
:
# by default, all script lines are interpreted as batch
# scripts to run before build
before_build
:
-
echo "Downloading boost..."
-
mkdir c:\projects\ethash\deps
-
cd c:\projects\ethash\deps
-
curl -O https://build.ethdev.com/builds/windows-precompiled/boost.tar.gz
-
echo "Unzipping boost..."
-
7z x boost.tar.gz > nul
-
7z x boost.tar > nul
-
ls
-
echo "Running cmake..."
-
cd c:\projects\ethash
-
cmake .
build
:
project
:
ALL_BUILD.vcxproj
# path to Visual Studio solution or project
after_build
:
-
echo "Running tests..."
-
cd c:\projects\ethash\test\c\Debug
-
Test.exe
-
echo "Finished!"
Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
0 → 100644
浏览文件 @
50659f4b
package
ethash
import
(
"bytes"
"crypto/rand"
"encoding/hex"
"log"
"math/big"
"os"
"sync"
"testing"
"github.com/ethereum/go-ethereum/common"
)
func
init
()
{
// glog.SetV(6)
// glog.SetToStderr(true)
}
type
testBlock
struct
{
difficulty
*
big
.
Int
hashNoNonce
common
.
Hash
nonce
uint64
mixDigest
common
.
Hash
number
uint64
}
func
(
b
*
testBlock
)
Difficulty
()
*
big
.
Int
{
return
b
.
difficulty
}
func
(
b
*
testBlock
)
HashNoNonce
()
common
.
Hash
{
return
b
.
hashNoNonce
}
func
(
b
*
testBlock
)
Nonce
()
uint64
{
return
b
.
nonce
}
func
(
b
*
testBlock
)
MixDigest
()
common
.
Hash
{
return
b
.
mixDigest
}
func
(
b
*
testBlock
)
NumberU64
()
uint64
{
return
b
.
number
}
var
validBlocks
=
[]
*
testBlock
{
// from proof of concept nine testnet, epoch 0
{
number
:
22
,
hashNoNonce
:
common
.
HexToHash
(
"372eca2454ead349c3df0ab5d00b0b706b23e49d469387db91811cee0358fc6d"
),
difficulty
:
big
.
NewInt
(
132416
),
nonce
:
0x495732e0ed7a801c
,
},
// from proof of concept nine testnet, epoch 1
{
number
:
30001
,
hashNoNonce
:
common
.
HexToHash
(
"7e44356ee3441623bc72a683fd3708fdf75e971bbe294f33e539eedad4b92b34"
),
difficulty
:
big
.
NewInt
(
1532671
),
nonce
:
0x318df1c8adef7e5e
,
},
// from proof of concept nine testnet, epoch 2
{
number
:
60000
,
hashNoNonce
:
common
.
HexToHash
(
"5fc898f16035bf5ac9c6d9077ae1e3d5fc1ecc3c9fd5bee8bb00e810fdacbaa0"
),
difficulty
:
big
.
NewInt
(
2467358
),
nonce
:
0x50377003e5d830ca
,
},
}
func
TestEthashVerifyValid
(
t
*
testing
.
T
)
{
eth
:=
New
()
for
i
,
block
:=
range
validBlocks
{
if
!
eth
.
Verify
(
block
)
{
t
.
Errorf
(
"block %d (%x) did not validate."
,
i
,
block
.
hashNoNonce
[
:
6
])
}
}
}
func
TestEthashConcurrentVerify
(
t
*
testing
.
T
)
{
eth
,
err
:=
NewForTesting
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
RemoveAll
(
eth
.
Full
.
Dir
)
block
:=
&
testBlock
{
difficulty
:
big
.
NewInt
(
10
)}
nonce
,
_
:=
eth
.
Search
(
block
,
nil
)
block
.
nonce
=
nonce
// Verify the block concurrently to check for data races.
var
wg
sync
.
WaitGroup
wg
.
Add
(
100
)
for
i
:=
0
;
i
<
100
;
i
++
{
go
func
()
{
if
!
eth
.
Verify
(
block
)
{
t
.
Error
(
"Block could not be verified"
)
}
wg
.
Done
()
}()
}
wg
.
Wait
()
}
func
TestEthashConcurrentSearch
(
t
*
testing
.
T
)
{
eth
,
err
:=
NewForTesting
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
eth
.
Turbo
(
true
)
defer
os
.
RemoveAll
(
eth
.
Full
.
Dir
)
// launch n searches concurrently.
var
(
block
=
&
testBlock
{
difficulty
:
big
.
NewInt
(
35000
)}
nsearch
=
10
wg
=
new
(
sync
.
WaitGroup
)
found
=
make
(
chan
uint64
)
stop
=
make
(
chan
struct
{})
)
rand
.
Read
(
block
.
hashNoNonce
[
:
])
wg
.
Add
(
nsearch
)
for
i
:=
0
;
i
<
nsearch
;
i
++
{
go
func
()
{
nonce
,
_
:=
eth
.
Search
(
block
,
stop
)
select
{
case
found
<-
nonce
:
case
<-
stop
:
}
wg
.
Done
()
}()
}
// wait for one of them to find the nonce
nonce
:=
<-
found
// stop the others
close
(
stop
)
wg
.
Wait
()
if
block
.
nonce
=
nonce
;
!
eth
.
Verify
(
block
)
{
t
.
Error
(
"Block could not be verified"
)
}
}
func
TestEthashSearchAcrossEpoch
(
t
*
testing
.
T
)
{
eth
,
err
:=
NewForTesting
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
RemoveAll
(
eth
.
Full
.
Dir
)
for
i
:=
epochLength
-
40
;
i
<
epochLength
+
40
;
i
++
{
block
:=
&
testBlock
{
number
:
i
,
difficulty
:
big
.
NewInt
(
90
)}
rand
.
Read
(
block
.
hashNoNonce
[
:
])
nonce
,
_
:=
eth
.
Search
(
block
,
nil
)
block
.
nonce
=
nonce
if
!
eth
.
Verify
(
block
)
{
t
.
Fatalf
(
"Block could not be verified"
)
}
}
}
func
TestGetSeedHash
(
t
*
testing
.
T
)
{
seed0
,
err
:=
GetSeedHash
(
0
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to get seedHash for block 0: %v"
,
err
)
}
if
bytes
.
Compare
(
seed0
,
make
([]
byte
,
32
))
!=
0
{
log
.
Printf
(
"seedHash for block 0 should be 0s, was: %v
\n
"
,
seed0
)
}
seed1
,
err
:=
GetSeedHash
(
30000
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
// From python:
// > from pyethash import get_seedhash
// > get_seedhash(30000)
expectedSeed1
,
err
:=
hex
.
DecodeString
(
"290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
bytes
.
Compare
(
seed1
,
expectedSeed1
)
!=
0
{
log
.
Printf
(
"seedHash for block 1 should be: %v,
\n
actual value: %v
\n
"
,
expectedSeed1
,
seed1
)
}
}
Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
0 → 100644
浏览文件 @
50659f4b
package
ethash
/*
#cgo CFLAGS: -std=gnu99 -Wall
#cgo LDFLAGS: -lm
#include "src/libethash/internal.c"
#include "src/libethash/sha3.c"
#include "src/libethash/io.c"
#ifdef _WIN32
# include "src/libethash/util_win32.c"
# include "src/libethash/io_win32.c"
# include "src/libethash/mmap_win32.c"
#else
# include "src/libethash/io_posix.c"
#endif
// 'gateway function' for calling back into go.
extern int ethashGoCallback(unsigned);
int ethashGoCallback_cgo(unsigned percent) { return ethashGoCallback(percent); }
*/
import
"C"
Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
浏览文件 @
50659f4b
#!/usr/bin/env python
#!/usr/bin/env python
import
os
from
distutils.core
import
setup
,
Extension
from
distutils.core
import
setup
,
Extension
sources
=
[
'src/python/core.c'
,
'src/libethash/io.c'
,
'src/libethash/internal.c'
,
'src/libethash/sha3.c'
]
if
os
.
name
==
'nt'
:
sources
+=
[
'src/libethash/util_win32.c'
,
'src/libethash/io_win32.c'
,
'src/libethash/mmap_win32.c'
,
]
else
:
sources
+=
[
'src/libethash/io_posix.c'
]
depends
=
[
'src/libethash/ethash.h'
,
'src/libethash/compiler.h'
,
'src/libethash/data_sizes.h'
,
'src/libethash/endian.h'
,
'src/libethash/ethash.h'
,
'src/libethash/io.h'
,
'src/libethash/fnv.h'
,
'src/libethash/internal.h'
,
'src/libethash/sha3.h'
,
'src/libethash/util.h'
,
]
pyethash
=
Extension
(
'pyethash'
,
pyethash
=
Extension
(
'pyethash'
,
sources
=
[
sources
=
sources
,
'src/python/core.c'
,
depends
=
depends
,
'src/libethash/util.c'
,
'src/libethash/internal.c'
,
'src/libethash/sha3.c'
],
depends
=
[
'src/libethash/ethash.h'
,
'src/libethash/compiler.h'
,
'src/libethash/data_sizes.h'
,
'src/libethash/endian.h'
,
'src/libethash/ethash.h'
,
'src/libethash/fnv.h'
,
'src/libethash/internal.h'
,
'src/libethash/sha3.h'
,
'src/libethash/util.h'
],
extra_compile_args
=
[
"-Isrc/"
,
"-std=gnu99"
,
"-Wall"
])
extra_compile_args
=
[
"-Isrc/"
,
"-std=gnu99"
,
"-Wall"
])
setup
(
setup
(
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt
浏览文件 @
50659f4b
...
@@ -3,56 +3,56 @@ include_directories(..)
...
@@ -3,56 +3,56 @@ include_directories(..)
set
(
CMAKE_BUILD_TYPE Release
)
set
(
CMAKE_BUILD_TYPE Release
)
if
(
MSVC
)
if
(
MSVC
)
add_definitions
(
"/openmp"
)
add_definitions
(
"/openmp"
)
endif
()
endif
()
# enable C++11, should probably be a bit more specific about compiler
# enable C++11, should probably be a bit more specific about compiler
if
(
NOT MSVC
)
if
(
NOT MSVC
)
SET
(
CMAKE_CXX_FLAGS
"-std=c++11"
)
SET
(
CMAKE_CXX_FLAGS
"-std=c++11"
)
endif
()
endif
()
if
(
NOT MPI_FOUND
)
if
(
NOT MPI_FOUND
)
find_package
(
MPI
)
find_package
(
MPI
)
endif
()
endif
()
if
(
NOT CRYPTOPP_FOUND
)
if
(
NOT CRYPTOPP_FOUND
)
find_package
(
CryptoPP 5.6.2
)
find_package
(
CryptoPP 5.6.2
)
endif
()
endif
()
if
(
CRYPTOPP_FOUND
)
if
(
CRYPTOPP_FOUND
)
add_definitions
(
-DWITH_CRYPTOPP
)
add_definitions
(
-DWITH_CRYPTOPP
)
find_package
(
Threads REQUIRED
)
endif
()
endif
()
if
(
NOT OpenCL_FOUND
)
if
(
NOT OpenCL_FOUND
)
find_package
(
OpenCL
)
find_package
(
OpenCL
)
endif
()
endif
()
if
(
OpenCL_FOUND
)
if
(
OpenCL_FOUND
)
add_definitions
(
-DWITH_OPENCL
)
add_definitions
(
-DWITH_OPENCL
)
include_directories
(
${
OpenCL_INCLUDE_DIRS
}
)
include_directories
(
${
OpenCL_INCLUDE_DIRS
}
)
list
(
APPEND FILES ethash_cl_miner.cpp ethash_cl_miner.h
)
list
(
APPEND FILES ethash_cl_miner.cpp ethash_cl_miner.h
)
endif
()
endif
()
if
(
MPI_FOUND
)
if
(
MPI_FOUND
)
include_directories
(
${
MPI_INCLUDE_PATH
}
)
include_directories
(
${
MPI_INCLUDE_PATH
}
)
add_executable
(
Benchmark_MPI_FULL benchmark.cpp
)
add_executable
(
Benchmark_MPI_FULL benchmark.cpp
)
target_link_libraries
(
Benchmark_MPI_FULL
${
ETHHASH_LIBS
}
${
MPI_LIBRARIES
}
)
target_link_libraries
(
Benchmark_MPI_FULL
${
ETHHASH_LIBS
}
${
MPI_LIBRARIES
}
${
CMAKE_THREAD_LIBS_INIT
}
)
SET_TARGET_PROPERTIES
(
Benchmark_MPI_FULL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
${
MPI_COMPILE_FLAGS
}
-DFULL -DMPI"
)
SET_TARGET_PROPERTIES
(
Benchmark_MPI_FULL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
${
MPI_COMPILE_FLAGS
}
-DFULL -DMPI"
)
add_executable
(
Benchmark_MPI_LIGHT benchmark.cpp
)
add_executable
(
Benchmark_MPI_LIGHT benchmark.cpp
)
target_link_libraries
(
Benchmark_MPI_LIGHT
${
ETHHASH_LIBS
}
${
MPI_LIBRARIES
}
)
target_link_libraries
(
Benchmark_MPI_LIGHT
${
ETHHASH_LIBS
}
${
MPI_LIBRARIES
}
${
CMAKE_THREAD_LIBS_INIT
}
)
SET_TARGET_PROPERTIES
(
Benchmark_MPI_LIGHT PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
${
MPI_COMPILE_FLAGS
}
-DMPI"
)
SET_TARGET_PROPERTIES
(
Benchmark_MPI_LIGHT PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
${
MPI_COMPILE_FLAGS
}
-DMPI"
)
endif
()
endif
()
add_executable
(
Benchmark_FULL benchmark.cpp
)
add_executable
(
Benchmark_FULL benchmark.cpp
)
target_link_libraries
(
Benchmark_FULL
${
ETHHASH_LIBS
}
)
target_link_libraries
(
Benchmark_FULL
${
ETHHASH_LIBS
}
${
CMAKE_THREAD_LIBS_INIT
}
)
SET_TARGET_PROPERTIES
(
Benchmark_FULL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
-DFULL"
)
SET_TARGET_PROPERTIES
(
Benchmark_FULL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
-DFULL"
)
add_executable
(
Benchmark_LIGHT benchmark.cpp
)
add_executable
(
Benchmark_LIGHT benchmark.cpp
)
target_link_libraries
(
Benchmark_LIGHT
${
ETHHASH_LIBS
}
)
target_link_libraries
(
Benchmark_LIGHT
${
ETHHASH_LIBS
}
${
CMAKE_THREAD_LIBS_INIT
}
)
if
(
OpenCL_FOUND
)
if
(
OpenCL_FOUND
)
add_executable
(
Benchmark_CL benchmark.cpp
)
add_executable
(
Benchmark_CL benchmark.cpp
)
target_link_libraries
(
Benchmark_CL
${
ETHHASH_LIBS
}
ethash-cl
)
target_link_libraries
(
Benchmark_CL
${
ETHHASH_LIBS
}
ethash-cl
${
CMAKE_THREAD_LIBS_INIT
}
)
SET_TARGET_PROPERTIES
(
Benchmark_CL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
-DOPENCL"
)
SET_TARGET_PROPERTIES
(
Benchmark_CL PROPERTIES COMPILE_FLAGS
"
${
COMPILE_FLAGS
}
-DOPENCL"
)
endif
()
endif
()
\ No newline at end of file
Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
浏览文件 @
50659f4b
...
@@ -96,6 +96,11 @@ static std::string bytesToHexString(uint8_t const* bytes, unsigned size)
...
@@ -96,6 +96,11 @@ static std::string bytesToHexString(uint8_t const* bytes, unsigned size)
return
str
;
return
str
;
}
}
static
std
::
string
bytesToHexString
(
ethash_h256_t
const
*
hash
,
unsigned
size
)
{
return
bytesToHexString
((
uint8_t
*
)
hash
,
size
);
}
extern
"C"
int
main
(
void
)
extern
"C"
int
main
(
void
)
{
{
// params for ethash
// params for ethash
...
@@ -106,12 +111,12 @@ extern "C" int main(void)
...
@@ -106,12 +111,12 @@ extern "C" int main(void)
//params.full_size = 8209 * 4096; // 8MBish;
//params.full_size = 8209 * 4096; // 8MBish;
//params.cache_size = 8209*4096;
//params.cache_size = 8209*4096;
//params.cache_size = 2053*4096;
//params.cache_size = 2053*4096;
ethash_
blockhash
_t
seed
;
ethash_
h256
_t
seed
;
ethash_
blockhash
_t
previous_hash
;
ethash_
h256
_t
previous_hash
;
memcpy
(
&
seed
,
hexStringToBytes
(
"9410b944535a83d9adf6bbdcc80e051f30676173c16ca0d32d6f1263fc246466"
).
data
(),
32
);
memcpy
(
&
seed
,
hexStringToBytes
(
"9410b944535a83d9adf6bbdcc80e051f30676173c16ca0d32d6f1263fc246466"
).
data
(),
32
);
memcpy
(
&
previous_hash
,
hexStringToBytes
(
"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
).
data
(),
32
);
memcpy
(
&
previous_hash
,
hexStringToBytes
(
"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
).
data
(),
32
);
// allocate page aligned buffer for dataset
// allocate page aligned buffer for dataset
#ifdef FULL
#ifdef FULL
void
*
full_mem_buf
=
malloc
(
params
.
full_size
+
4095
);
void
*
full_mem_buf
=
malloc
(
params
.
full_size
+
4095
);
...
@@ -122,24 +127,24 @@ extern "C" int main(void)
...
@@ -122,24 +127,24 @@ extern "C" int main(void)
ethash_cache
cache
;
ethash_cache
cache
;
cache
.
mem
=
cache_mem
;
cache
.
mem
=
cache_mem
;
// compute cache or full data
// compute cache or full data
{
{
auto
startTime
=
high_resolution_clock
::
now
();
auto
startTime
=
high_resolution_clock
::
now
();
ethash_mkcache
(
&
cache
,
&
params
,
seed
);
ethash_mkcache
(
&
cache
,
&
params
,
&
seed
);
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
ethash_
blockhash
_t
cache_hash
;
ethash_
h256
_t
cache_hash
;
SHA3_256
(
&
cache_hash
,
(
uint8_t
const
*
)
cache_mem
,
params
.
cache_size
);
SHA3_256
(
&
cache_hash
,
(
uint8_t
const
*
)
cache_mem
,
params
.
cache_size
);
debugf
(
"ethash_mkcache: %ums, sha3: %s
\n
"
,
(
unsigned
)((
time
*
1000
)
/
CLOCKS_PER_SEC
),
bytesToHexString
(
cache_hash
,
sizeof
(
cache_hash
)).
data
());
debugf
(
"ethash_mkcache: %ums, sha3: %s
\n
"
,
(
unsigned
)((
time
*
1000
)
/
CLOCKS_PER_SEC
),
bytesToHexString
(
&
cache_hash
,
sizeof
(
cache_hash
)).
data
());
// print a couple of test hashes
// print a couple of test hashes
{
{
auto
startTime
=
high_resolution_clock
::
now
();
auto
startTime
=
high_resolution_clock
::
now
();
ethash_return_value
hash
;
ethash_return_value
hash
;
ethash_light
(
&
hash
,
&
cache
,
&
params
,
previous_hash
,
0
);
ethash_light
(
&
hash
,
&
cache
,
&
params
,
&
previous_hash
,
0
);
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
debugf
(
"ethash_light test: %ums, %s
\n
"
,
(
unsigned
)
time
,
bytesToHexString
(
hash
.
result
,
32
).
data
());
debugf
(
"ethash_light test: %ums, %s
\n
"
,
(
unsigned
)
time
,
bytesToHexString
(
&
hash
.
result
,
32
).
data
());
}
}
#ifdef FULL
#ifdef FULL
...
@@ -154,34 +159,34 @@ extern "C" int main(void)
...
@@ -154,34 +159,34 @@ extern "C" int main(void)
ethash_cl_miner
miner
;
ethash_cl_miner
miner
;
{
{
auto
startTime
=
high_resolution_clock
::
now
();
auto
startTime
=
high_resolution_clock
::
now
();
if
(
!
miner
.
init
(
params
,
seed
))
if
(
!
miner
.
init
(
params
,
&
seed
))
exit
(
-
1
);
exit
(
-
1
);
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
debugf
(
"ethash_cl_miner init: %ums
\n
"
,
(
unsigned
)
time
);
debugf
(
"ethash_cl_miner init: %ums
\n
"
,
(
unsigned
)
time
);
}
}
#endif
#endif
#ifdef FULL
#ifdef FULL
{
{
auto
startTime
=
high_resolution_clock
::
now
();
auto
startTime
=
high_resolution_clock
::
now
();
ethash_return_value
hash
;
ethash_return_value
hash
;
ethash_full
(
&
hash
,
full_mem
,
&
params
,
previous_hash
,
0
);
ethash_full
(
&
hash
,
full_mem
,
&
params
,
&
previous_hash
,
0
);
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
debugf
(
"ethash_full test: %uns, %
s
\n
"
,
(
unsigned
)
time
);
debugf
(
"ethash_full test: %un
s
\n
"
,
(
unsigned
)
time
);
}
}
#endif
#endif
#ifdef OPENCL
#ifdef OPENCL
// validate 1024 hashes against CPU
// validate 1024 hashes against CPU
miner
.
hash
(
g_hashes
,
previous_hash
,
0
,
1024
);
miner
.
hash
(
g_hashes
,
(
uint8_t
*
)
&
previous_hash
,
0
,
1024
);
for
(
unsigned
i
=
0
;
i
!=
1024
;
++
i
)
for
(
unsigned
i
=
0
;
i
!=
1024
;
++
i
)
{
{
ethash_return_value
hash
;
ethash_return_value
hash
;
ethash_light
(
&
hash
,
&
cache
,
&
params
,
previous_hash
,
i
);
ethash_light
(
&
hash
,
&
cache
,
&
params
,
&
previous_hash
,
i
);
if
(
memcmp
(
hash
.
result
,
g_hashes
+
32
*
i
,
32
)
!=
0
)
if
(
memcmp
(
&
hash
.
result
,
g_hashes
+
32
*
i
,
32
)
!=
0
)
{
{
debugf
(
"nonce %u failed: %s %s
\n
"
,
i
,
bytesToHexString
(
g_hashes
+
32
*
i
,
32
).
c_str
(),
bytesToHexString
(
hash
.
result
,
32
).
c_str
());
debugf
(
"nonce %u failed: %s %s
\n
"
,
i
,
bytesToHexString
(
g_hashes
+
32
*
i
,
32
).
c_str
(),
bytesToHexString
(
&
hash
.
result
,
32
).
c_str
());
static
unsigned
c
=
0
;
static
unsigned
c
=
0
;
if
(
++
c
==
16
)
if
(
++
c
==
16
)
{
{
...
@@ -189,14 +194,14 @@ extern "C" int main(void)
...
@@ -189,14 +194,14 @@ extern "C" int main(void)
}
}
}
}
}
}
// ensure nothing else is going on
// ensure nothing else is going on
miner
.
finish
();
miner
.
finish
();
#endif
#endif
auto
startTime
=
high_resolution_clock
::
now
();
auto
startTime
=
high_resolution_clock
::
now
();
unsigned
hash_count
=
trials
;
unsigned
hash_count
=
trials
;
#ifdef OPENCL
#ifdef OPENCL
{
{
struct
search_hook
:
ethash_cl_miner
::
search_hook
struct
search_hook
:
ethash_cl_miner
::
search_hook
...
@@ -220,14 +225,14 @@ extern "C" int main(void)
...
@@ -220,14 +225,14 @@ extern "C" int main(void)
search_hook
hook
;
search_hook
hook
;
hook
.
hash_count
=
0
;
hook
.
hash_count
=
0
;
miner
.
search
(
previous_hash
,
0x000000ffffffffff
,
hook
);
miner
.
search
(
(
uint8_t
*
)
&
previous_hash
,
0x000000ffffffffff
,
hook
);
for
(
unsigned
i
=
0
;
i
!=
hook
.
nonce_vec
.
size
();
++
i
)
for
(
unsigned
i
=
0
;
i
!=
hook
.
nonce_vec
.
size
();
++
i
)
{
{
uint64_t
nonce
=
hook
.
nonce_vec
[
i
];
uint64_t
nonce
=
hook
.
nonce_vec
[
i
];
ethash_return_value
hash
;
ethash_return_value
hash
;
ethash_light
(
&
hash
,
&
cache
,
&
params
,
previous_hash
,
nonce
);
ethash_light
(
&
hash
,
&
cache
,
&
params
,
&
previous_hash
,
nonce
);
debugf
(
"found: %.8x%.8x -> %s
\n
"
,
unsigned
(
nonce
>>
32
),
unsigned
(
nonce
),
bytesToHexString
(
hash
.
result
,
32
).
c_str
());
debugf
(
"found: %.8x%.8x -> %s
\n
"
,
unsigned
(
nonce
>>
32
),
unsigned
(
nonce
),
bytesToHexString
(
&
hash
.
result
,
32
).
c_str
());
}
}
hash_count
=
hook
.
hash_count
;
hash_count
=
hook
.
hash_count
;
...
@@ -239,9 +244,9 @@ extern "C" int main(void)
...
@@ -239,9 +244,9 @@ extern "C" int main(void)
{
{
ethash_return_value
hash
;
ethash_return_value
hash
;
#ifdef FULL
#ifdef FULL
ethash_full
(
&
hash
,
full_mem
,
&
params
,
previous_hash
,
nonce
);
ethash_full
(
&
hash
,
full_mem
,
&
params
,
&
previous_hash
,
nonce
);
#else
#else
ethash_light
(
&
hash
,
&
cache
,
&
params
,
previous_hash
,
nonce
);
ethash_light
(
&
hash
,
&
cache
,
&
params
,
&
previous_hash
,
nonce
);
#endif // FULL
#endif // FULL
}
}
}
}
...
@@ -249,7 +254,7 @@ extern "C" int main(void)
...
@@ -249,7 +254,7 @@ extern "C" int main(void)
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
auto
time
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
high_resolution_clock
::
now
()
-
startTime
).
count
();
debugf
(
"Search took: %ums
\n
"
,
(
unsigned
)
time
/
1000
);
debugf
(
"Search took: %ums
\n
"
,
(
unsigned
)
time
/
1000
);
unsigned
read_size
=
ACCESSES
*
MIX_BYTES
;
unsigned
read_size
=
ETHASH_ACCESSES
*
ETHASH_
MIX_BYTES
;
#if defined(OPENCL) || defined(FULL)
#if defined(OPENCL) || defined(FULL)
debugf
(
debugf
(
"hashrate: %8.2f Mh/s, bw: %8.2f GB/s
\n
"
,
"hashrate: %8.2f Mh/s, bw: %8.2f GB/s
\n
"
,
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
浏览文件 @
50659f4b
...
@@ -13,7 +13,7 @@ if (NOT MSVC)
...
@@ -13,7 +13,7 @@ if (NOT MSVC)
set
(
CMAKE_CXX_FLAGS
"-Wall -std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"-Wall -std=c++11"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
set
(
CMAKE_CXX_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O
4
-DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O
3
-DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O2 -g"
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O2 -g"
)
# Compiler-specific C++11 activation.
# Compiler-specific C++11 activation.
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
浏览文件 @
50659f4b
...
@@ -24,12 +24,15 @@
...
@@ -24,12 +24,15 @@
#include <cstdio>
#include <cstdio>
#include <cstdlib>
#include <cstdlib>
#include <iostream>
#include <assert.h>
#include <assert.h>
#include <queue>
#include <queue>
#include <vector>
#include <vector>
#include <libethash/util.h>
#include <libethash/ethash.h>
#include <libethash/internal.h>
#include "ethash_cl_miner.h"
#include "ethash_cl_miner.h"
#include "ethash_cl_miner_kernel.h"
#include "ethash_cl_miner_kernel.h"
#include <libethash/util.h>
#define ETHASH_BYTES 32
#define ETHASH_BYTES 32
...
@@ -42,6 +45,8 @@
...
@@ -42,6 +45,8 @@
#undef min
#undef min
#undef max
#undef max
using
namespace
std
;
static
void
add_definition
(
std
::
string
&
source
,
char
const
*
id
,
unsigned
value
)
static
void
add_definition
(
std
::
string
&
source
,
char
const
*
id
,
unsigned
value
)
{
{
char
buf
[
256
];
char
buf
[
256
];
...
@@ -49,52 +54,108 @@ static void add_definition(std::string& source, char const* id, unsigned value)
...
@@ -49,52 +54,108 @@ static void add_definition(std::string& source, char const* id, unsigned value)
source
.
insert
(
source
.
begin
(),
buf
,
buf
+
strlen
(
buf
));
source
.
insert
(
source
.
begin
(),
buf
,
buf
+
strlen
(
buf
));
}
}
ethash_cl_miner
::
search_hook
::~
search_hook
()
{}
ethash_cl_miner
::
ethash_cl_miner
()
ethash_cl_miner
::
ethash_cl_miner
()
:
m_opencl_1_1
()
:
m_opencl_1_1
()
{
{
}
}
bool
ethash_cl_miner
::
init
(
ethash_params
const
&
params
,
ethash_blockhash_t
const
*
seed
,
unsigned
workgroup_size
)
std
::
string
ethash_cl_miner
::
platform_info
(
unsigned
_platformId
,
unsigned
_deviceId
)
{
std
::
vector
<
cl
::
Platform
>
platforms
;
cl
::
Platform
::
get
(
&
platforms
);
if
(
platforms
.
empty
())
{
cout
<<
"No OpenCL platforms found."
<<
endl
;
return
std
::
string
();
}
// get GPU device of the selected platform
std
::
vector
<
cl
::
Device
>
devices
;
unsigned
platform_num
=
std
::
min
<
unsigned
>
(
_platformId
,
platforms
.
size
()
-
1
);
platforms
[
platform_num
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
if
(
devices
.
empty
())
{
cout
<<
"No OpenCL devices found."
<<
endl
;
return
std
::
string
();
}
// use selected default device
unsigned
device_num
=
std
::
min
<
unsigned
>
(
_deviceId
,
devices
.
size
()
-
1
);
cl
::
Device
&
device
=
devices
[
device_num
];
std
::
string
device_version
=
device
.
getInfo
<
CL_DEVICE_VERSION
>
();
return
"{
\"
platform
\"
:
\"
"
+
platforms
[
platform_num
].
getInfo
<
CL_PLATFORM_NAME
>
()
+
"
\"
,
\"
device
\"
:
\"
"
+
device
.
getInfo
<
CL_DEVICE_NAME
>
()
+
"
\"
,
\"
version
\"
:
\"
"
+
device_version
+
"
\"
}"
;
}
unsigned
ethash_cl_miner
::
get_num_devices
(
unsigned
_platformId
)
{
std
::
vector
<
cl
::
Platform
>
platforms
;
cl
::
Platform
::
get
(
&
platforms
);
if
(
platforms
.
empty
())
{
cout
<<
"No OpenCL platforms found."
<<
endl
;
return
0
;
}
std
::
vector
<
cl
::
Device
>
devices
;
unsigned
platform_num
=
std
::
min
<
unsigned
>
(
_platformId
,
platforms
.
size
()
-
1
);
platforms
[
platform_num
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
if
(
devices
.
empty
())
{
cout
<<
"No OpenCL devices found."
<<
endl
;
return
0
;
}
return
devices
.
size
();
}
void
ethash_cl_miner
::
finish
()
{
if
(
m_queue
())
m_queue
.
finish
();
}
bool
ethash_cl_miner
::
init
(
uint64_t
block_number
,
std
::
function
<
void
(
void
*
)
>
_fillDAG
,
unsigned
workgroup_size
,
unsigned
_platformId
,
unsigned
_deviceId
)
{
{
// store params
// store params
m_
params
=
params
;
m_
fullSize
=
ethash_get_datasize
(
block_number
)
;
// get all platforms
// get all platforms
std
::
vector
<
cl
::
Platform
>
platforms
;
std
::
vector
<
cl
::
Platform
>
platforms
;
cl
::
Platform
::
get
(
&
platforms
);
cl
::
Platform
::
get
(
&
platforms
);
if
(
platforms
.
empty
())
if
(
platforms
.
empty
())
{
{
debugf
(
"No OpenCL platforms found.
\n
"
)
;
cout
<<
"No OpenCL platforms found."
<<
endl
;
return
false
;
return
false
;
}
}
// use
default
platform
// use
selected
platform
debugf
(
"Using platform: %s
\n
"
,
platforms
[
0
].
getInfo
<
CL_PLATFORM_NAME
>
().
c_str
()
);
_platformId
=
std
::
min
<
unsigned
>
(
_platformId
,
platforms
.
size
()
-
1
);
// get GPU device of the default platform
cout
<<
"Using platform: "
<<
platforms
[
_platformId
].
getInfo
<
CL_PLATFORM_NAME
>
().
c_str
()
<<
endl
;
std
::
vector
<
cl
::
Device
>
devices
;
platforms
[
0
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
// get GPU device of the default platform
if
(
devices
.
empty
())
std
::
vector
<
cl
::
Device
>
devices
;
platforms
[
_platformId
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
if
(
devices
.
empty
())
{
{
debugf
(
"No OpenCL devices found.
\n
"
)
;
cout
<<
"No OpenCL devices found."
<<
endl
;
return
false
;
return
false
;
}
}
// use default device
// use selected device
unsigned
device_num
=
0
;
cl
::
Device
&
device
=
devices
[
std
::
min
<
unsigned
>
(
_deviceId
,
devices
.
size
()
-
1
)];
cl
::
Device
&
device
=
devices
[
device_num
];
std
::
string
device_version
=
device
.
getInfo
<
CL_DEVICE_VERSION
>
();
std
::
string
device_version
=
device
.
getInfo
<
CL_DEVICE_VERSION
>
();
debugf
(
"Using device: %s (%s)
\n
"
,
device
.
getInfo
<
CL_DEVICE_NAME
>
().
c_str
(),
device_version
.
c_str
())
;
cout
<<
"Using device: "
<<
device
.
getInfo
<
CL_DEVICE_NAME
>
().
c_str
()
<<
"("
<<
device_version
.
c_str
()
<<
")"
<<
endl
;
if
(
strncmp
(
"OpenCL 1.0"
,
device_version
.
c_str
(),
10
)
==
0
)
if
(
strncmp
(
"OpenCL 1.0"
,
device_version
.
c_str
(),
10
)
==
0
)
{
{
debugf
(
"OpenCL 1.0 is not supported.
\n
"
)
;
cout
<<
"OpenCL 1.0 is not supported."
<<
endl
;
return
false
;
return
false
;
}
}
if
(
strncmp
(
"OpenCL 1.1"
,
device_version
.
c_str
(),
10
)
==
0
)
if
(
strncmp
(
"OpenCL 1.1"
,
device_version
.
c_str
(),
10
)
==
0
)
{
m_opencl_1_1
=
true
;
m_opencl_1_1
=
true
;
}
// create context
// create context
m_context
=
cl
::
Context
(
std
::
vector
<
cl
::
Device
>
(
&
device
,
&
device
+
1
));
m_context
=
cl
::
Context
(
std
::
vector
<
cl
::
Device
>
(
&
device
,
&
device
+
1
));
...
@@ -106,8 +167,8 @@ bool ethash_cl_miner::init(ethash_params const& params, ethash_blockhash_t const
...
@@ -106,8 +167,8 @@ bool ethash_cl_miner::init(ethash_params const& params, ethash_blockhash_t const
// patch source code
// patch source code
std
::
string
code
(
ETHASH_CL_MINER_KERNEL
,
ETHASH_CL_MINER_KERNEL
+
ETHASH_CL_MINER_KERNEL_SIZE
);
std
::
string
code
(
ETHASH_CL_MINER_KERNEL
,
ETHASH_CL_MINER_KERNEL
+
ETHASH_CL_MINER_KERNEL_SIZE
);
add_definition
(
code
,
"GROUP_SIZE"
,
m_workgroup_size
);
add_definition
(
code
,
"GROUP_SIZE"
,
m_workgroup_size
);
add_definition
(
code
,
"DAG_SIZE"
,
(
unsigned
)(
params
.
full_size
/
MIX_BYTES
));
add_definition
(
code
,
"DAG_SIZE"
,
(
unsigned
)(
m_fullSize
/
ETHASH_
MIX_BYTES
));
add_definition
(
code
,
"ACCESSES"
,
ACCESSES
);
add_definition
(
code
,
"ACCESSES"
,
ETHASH_
ACCESSES
);
add_definition
(
code
,
"MAX_OUTPUTS"
,
c_max_search_results
);
add_definition
(
code
,
"MAX_OUTPUTS"
,
c_max_search_results
);
//debugf("%s", code.c_str());
//debugf("%s", code.c_str());
...
@@ -122,31 +183,25 @@ bool ethash_cl_miner::init(ethash_params const& params, ethash_blockhash_t const
...
@@ -122,31 +183,25 @@ bool ethash_cl_miner::init(ethash_params const& params, ethash_blockhash_t const
}
}
catch
(
cl
::
Error
err
)
catch
(
cl
::
Error
err
)
{
{
debugf
(
"%s
\n
"
,
program
.
getBuildInfo
<
CL_PROGRAM_BUILD_LOG
>
(
device
).
c_str
()
);
cout
<<
program
.
getBuildInfo
<
CL_PROGRAM_BUILD_LOG
>
(
device
).
c_str
(
);
return
false
;
return
false
;
}
}
m_hash_kernel
=
cl
::
Kernel
(
program
,
"ethash_hash"
);
m_hash_kernel
=
cl
::
Kernel
(
program
,
"ethash_hash"
);
m_search_kernel
=
cl
::
Kernel
(
program
,
"ethash_search"
);
m_search_kernel
=
cl
::
Kernel
(
program
,
"ethash_search"
);
// create buffer for dag
// create buffer for dag
m_dag
=
cl
::
Buffer
(
m_context
,
CL_MEM_READ_ONLY
,
params
.
full_s
ize
);
m_dag
=
cl
::
Buffer
(
m_context
,
CL_MEM_READ_ONLY
,
m_fullS
ize
);
// create buffer for header
// create buffer for header
m_header
=
cl
::
Buffer
(
m_context
,
CL_MEM_READ_ONLY
,
32
);
m_header
=
cl
::
Buffer
(
m_context
,
CL_MEM_READ_ONLY
,
32
);
// compute dag on CPU
// compute dag on CPU
{
{
void
*
cache_mem
=
malloc
(
params
.
cache_size
+
63
);
ethash_cache
cache
;
cache
.
mem
=
(
void
*
)(((
uintptr_t
)
cache_mem
+
63
)
&
~
63
);
ethash_mkcache
(
&
cache
,
&
params
,
seed
);
// if this throws then it's because we probably need to subdivide the dag uploads for compatibility
// if this throws then it's because we probably need to subdivide the dag uploads for compatibility
void
*
dag_ptr
=
m_queue
.
enqueueMapBuffer
(
m_dag
,
true
,
m_opencl_1_1
?
CL_MAP_WRITE
:
CL_MAP_WRITE_INVALIDATE_REGION
,
0
,
params
.
full_size
);
void
*
dag_ptr
=
m_queue
.
enqueueMapBuffer
(
m_dag
,
true
,
m_opencl_1_1
?
CL_MAP_WRITE
:
CL_MAP_WRITE_INVALIDATE_REGION
,
0
,
m_fullSize
);
ethash_compute_full_data
(
dag_ptr
,
&
params
,
&
cache
);
// memcpying 1GB: horrible... really. horrible. but necessary since we can't mmap *and* gpumap.
_fillDAG
(
dag_ptr
);
m_queue
.
enqueueUnmapMemObject
(
m_dag
,
dag_ptr
);
m_queue
.
enqueueUnmapMemObject
(
m_dag
,
dag_ptr
);
free
(
cache_mem
);
}
}
// create mining buffers
// create mining buffers
...
@@ -167,7 +222,7 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
...
@@ -167,7 +222,7 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
unsigned
buf
;
unsigned
buf
;
};
};
std
::
queue
<
pending_batch
>
pending
;
std
::
queue
<
pending_batch
>
pending
;
// update header constant buffer
// update header constant buffer
m_queue
.
enqueueWriteBuffer
(
m_header
,
true
,
0
,
32
,
header
);
m_queue
.
enqueueWriteBuffer
(
m_header
,
true
,
0
,
32
,
header
);
...
@@ -191,8 +246,8 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
...
@@ -191,8 +246,8 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
// how many this batch
// how many this batch
if
(
i
<
count
)
if
(
i
<
count
)
{
{
unsigned
const
this_count
=
std
::
min
(
count
-
i
,
c_hash_batch_size
);
unsigned
const
this_count
=
std
::
min
<
unsigned
>
(
count
-
i
,
c_hash_batch_size
);
unsigned
const
batch_count
=
std
::
max
(
this_count
,
m_workgroup_size
);
unsigned
const
batch_count
=
std
::
max
<
unsigned
>
(
this_count
,
m_workgroup_size
);
// supply output hash buffer to kernel
// supply output hash buffer to kernel
m_hash_kernel
.
setArg
(
0
,
m_hash_buf
[
buf
]);
m_hash_kernel
.
setArg
(
0
,
m_hash_buf
[
buf
]);
...
@@ -205,7 +260,7 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
...
@@ -205,7 +260,7 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
cl
::
NDRange
(
m_workgroup_size
)
cl
::
NDRange
(
m_workgroup_size
)
);
);
m_queue
.
flush
();
m_queue
.
flush
();
pending
.
push
({
i
,
this_count
,
buf
});
pending
.
push
({
i
,
this_count
,
buf
});
i
+=
this_count
;
i
+=
this_count
;
buf
=
(
buf
+
1
)
%
c_num_buffers
;
buf
=
(
buf
+
1
)
%
c_num_buffers
;
...
@@ -245,7 +300,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
...
@@ -245,7 +300,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
m_queue
.
enqueueWriteBuffer
(
m_search_buf
[
i
],
false
,
0
,
4
,
&
c_zero
);
m_queue
.
enqueueWriteBuffer
(
m_search_buf
[
i
],
false
,
0
,
4
,
&
c_zero
);
}
}
#if CL_VERSION_1_2
#if CL_VERSION_1_2
&& 0
cl
::
Event
pre_return_event
;
cl
::
Event
pre_return_event
;
if
(
!
m_opencl_1_1
)
if
(
!
m_opencl_1_1
)
{
{
...
@@ -284,7 +339,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
...
@@ -284,7 +339,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
// execute it!
// execute it!
m_queue
.
enqueueNDRangeKernel
(
m_search_kernel
,
cl
::
NullRange
,
c_search_batch_size
,
m_workgroup_size
);
m_queue
.
enqueueNDRangeKernel
(
m_search_kernel
,
cl
::
NullRange
,
c_search_batch_size
,
m_workgroup_size
);
pending
.
push
({
start_nonce
,
buf
});
pending
.
push
({
start_nonce
,
buf
});
buf
=
(
buf
+
1
)
%
c_num_buffers
;
buf
=
(
buf
+
1
)
%
c_num_buffers
;
...
@@ -295,16 +350,16 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
...
@@ -295,16 +350,16 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
// could use pinned host pointer instead
// could use pinned host pointer instead
uint32_t
*
results
=
(
uint32_t
*
)
m_queue
.
enqueueMapBuffer
(
m_search_buf
[
batch
.
buf
],
true
,
CL_MAP_READ
,
0
,
(
1
+
c_max_search_results
)
*
sizeof
(
uint32_t
));
uint32_t
*
results
=
(
uint32_t
*
)
m_queue
.
enqueueMapBuffer
(
m_search_buf
[
batch
.
buf
],
true
,
CL_MAP_READ
,
0
,
(
1
+
c_max_search_results
)
*
sizeof
(
uint32_t
));
unsigned
num_found
=
std
::
min
(
results
[
0
],
c_max_search_results
);
unsigned
num_found
=
std
::
min
<
unsigned
>
(
results
[
0
],
c_max_search_results
);
uint64_t
nonces
[
c_max_search_results
];
uint64_t
nonces
[
c_max_search_results
];
for
(
unsigned
i
=
0
;
i
!=
num_found
;
++
i
)
for
(
unsigned
i
=
0
;
i
!=
num_found
;
++
i
)
{
{
nonces
[
i
]
=
batch
.
start_nonce
+
results
[
i
+
1
];
nonces
[
i
]
=
batch
.
start_nonce
+
results
[
i
+
1
];
}
}
m_queue
.
enqueueUnmapMemObject
(
m_search_buf
[
batch
.
buf
],
results
);
m_queue
.
enqueueUnmapMemObject
(
m_search_buf
[
batch
.
buf
],
results
);
bool
exit
=
num_found
&&
hook
.
found
(
nonces
,
num_found
);
bool
exit
=
num_found
&&
hook
.
found
(
nonces
,
num_found
);
exit
|=
hook
.
searched
(
batch
.
start_nonce
,
c_search_batch_size
);
// always report searched before exit
exit
|=
hook
.
searched
(
batch
.
start_nonce
,
c_search_batch_size
);
// always report searched before exit
if
(
exit
)
if
(
exit
)
...
@@ -319,7 +374,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
...
@@ -319,7 +374,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
}
}
// not safe to return until this is ready
// not safe to return until this is ready
#if CL_VERSION_1_2
#if CL_VERSION_1_2
&& 0
if
(
!
m_opencl_1_1
)
if
(
!
m_opencl_1_1
)
{
{
pre_return_event
.
wait
();
pre_return_event
.
wait
();
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
浏览文件 @
50659f4b
#pragma once
#pragma once
#define __CL_ENABLE_EXCEPTIONS
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#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"
#include "cl.hpp"
#endif
#include <time.h>
#include <time.h>
#include <functional>
#include <libethash/ethash.h>
#include <libethash/ethash.h>
class
ethash_cl_miner
class
ethash_cl_miner
...
@@ -11,6 +21,8 @@ class ethash_cl_miner
...
@@ -11,6 +21,8 @@ class ethash_cl_miner
public:
public:
struct
search_hook
struct
search_hook
{
{
virtual
~
search_hook
();
// always a virtual destructor for a class with virtuals.
// reports progress, return true to abort
// reports progress, return true to abort
virtual
bool
found
(
uint64_t
const
*
nonces
,
uint32_t
count
)
=
0
;
virtual
bool
found
(
uint64_t
const
*
nonces
,
uint32_t
count
)
=
0
;
virtual
bool
searched
(
uint64_t
start_nonce
,
uint32_t
count
)
=
0
;
virtual
bool
searched
(
uint64_t
start_nonce
,
uint32_t
count
)
=
0
;
...
@@ -19,19 +31,19 @@ public:
...
@@ -19,19 +31,19 @@ public:
public:
public:
ethash_cl_miner
();
ethash_cl_miner
();
bool
init
(
ethash_params
const
&
params
,
ethash_blockhash_t
const
*
seed
,
unsigned
workgroup_size
=
64
);
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
finish
();
void
hash
(
uint8_t
*
ret
,
uint8_t
const
*
header
,
uint64_t
nonce
,
unsigned
count
);
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
);
void
search
(
uint8_t
const
*
header
,
uint64_t
target
,
search_hook
&
hook
);
private:
private:
static
unsigned
const
c_max_search_results
=
63
;
enum
{
c_max_search_results
=
63
,
c_num_buffers
=
2
,
c_hash_batch_size
=
1024
,
c_search_batch_size
=
1024
*
256
};
static
unsigned
const
c_num_buffers
=
2
;
static
unsigned
const
c_hash_batch_size
=
1024
;
static
unsigned
const
c_search_batch_size
=
1024
*
256
;
ethash_params
m_params
;
uint64_t
m_fullSize
;
cl
::
Context
m_context
;
cl
::
Context
m_context
;
cl
::
CommandQueue
m_queue
;
cl
::
CommandQueue
m_queue
;
cl
::
Kernel
m_hash_kernel
;
cl
::
Kernel
m_hash_kernel
;
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner_kernel.cl
浏览文件 @
50659f4b
...
@@ -415,8 +415,7 @@ __kernel void ethash_search_simple(
...
@@ -415,8 +415,7 @@ __kernel void ethash_search_simple(
{
{
uint
const
gid
=
get_global_id
(
0
)
;
uint
const
gid
=
get_global_id
(
0
)
;
hash32_t
hash
=
compute_hash_simple
(
g_header,
g_dag,
start_nonce
+
gid,
isolate
)
;
hash32_t
hash
=
compute_hash_simple
(
g_header,
g_dag,
start_nonce
+
gid,
isolate
)
;
if
(
as_ulong
(
as_uchar8
(
hash.ulongs[0]
)
.
s76543210
)
<
target
)
if
(
hash.ulongs[countof
(
hash.ulongs
)
-1]
<
target
)
{
{
uint
slot
=
min
(
MAX_OUTPUTS,
atomic_inc
(
&g_output[0]
)
+
1
)
;
uint
slot
=
min
(
MAX_OUTPUTS,
atomic_inc
(
&g_output[0]
)
+
1
)
;
g_output[slot]
=
gid
;
g_output[slot]
=
gid
;
...
@@ -453,7 +452,7 @@ __kernel void ethash_search(
...
@@ -453,7 +452,7 @@ __kernel void ethash_search(
uint
const
gid
=
get_global_id
(
0
)
;
uint
const
gid
=
get_global_id
(
0
)
;
hash32_t
hash
=
compute_hash
(
share,
g_header,
g_dag,
start_nonce
+
gid,
isolate
)
;
hash32_t
hash
=
compute_hash
(
share,
g_header,
g_dag,
start_nonce
+
gid,
isolate
)
;
if
(
hash.ulongs[countof
(
hash.ulongs
)
-1]
<
target
)
if
(
as_ulong
(
as_uchar8
(
hash.ulongs[0]
)
.
s76543210
)
<
target
)
{
{
uint
slot
=
min
(
MAX_OUTPUTS,
atomic_inc
(
&g_output[0]
)
+
1
)
;
uint
slot
=
min
(
MAX_OUTPUTS,
atomic_inc
(
&g_output[0]
)
+
1
)
;
g_output[slot]
=
gid
;
g_output[slot]
=
gid
;
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
浏览文件 @
50659f4b
...
@@ -10,8 +10,7 @@ if (NOT MSVC)
...
@@ -10,8 +10,7 @@ if (NOT MSVC)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-std=gnu99"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-std=gnu99"
)
endif
()
endif
()
set
(
FILES util.c
set
(
FILES util.h
util.h
io.c
io.c
internal.c
internal.c
ethash.h
ethash.h
...
@@ -21,7 +20,7 @@ set(FILES util.c
...
@@ -21,7 +20,7 @@ set(FILES util.c
data_sizes.h
)
data_sizes.h
)
if
(
MSVC
)
if
(
MSVC
)
list
(
APPEND FILES
io
_win32.c
)
list
(
APPEND FILES
util_win32.c io_win32.c mmap
_win32.c
)
else
()
else
()
list
(
APPEND FILES io_posix.c
)
list
(
APPEND FILES io_posix.c
)
endif
()
endif
()
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
浏览文件 @
50659f4b
...
@@ -3,38 +3,6 @@
...
@@ -3,38 +3,6 @@
#include <stdint.h>
#include <stdint.h>
#include "compiler.h"
#include "compiler.h"
static
const
uint8_t
BitReverseTable256
[]
=
{
0x00
,
0x80
,
0x40
,
0xC0
,
0x20
,
0xA0
,
0x60
,
0xE0
,
0x10
,
0x90
,
0x50
,
0xD0
,
0x30
,
0xB0
,
0x70
,
0xF0
,
0x08
,
0x88
,
0x48
,
0xC8
,
0x28
,
0xA8
,
0x68
,
0xE8
,
0x18
,
0x98
,
0x58
,
0xD8
,
0x38
,
0xB8
,
0x78
,
0xF8
,
0x04
,
0x84
,
0x44
,
0xC4
,
0x24
,
0xA4
,
0x64
,
0xE4
,
0x14
,
0x94
,
0x54
,
0xD4
,
0x34
,
0xB4
,
0x74
,
0xF4
,
0x0C
,
0x8C
,
0x4C
,
0xCC
,
0x2C
,
0xAC
,
0x6C
,
0xEC
,
0x1C
,
0x9C
,
0x5C
,
0xDC
,
0x3C
,
0xBC
,
0x7C
,
0xFC
,
0x02
,
0x82
,
0x42
,
0xC2
,
0x22
,
0xA2
,
0x62
,
0xE2
,
0x12
,
0x92
,
0x52
,
0xD2
,
0x32
,
0xB2
,
0x72
,
0xF2
,
0x0A
,
0x8A
,
0x4A
,
0xCA
,
0x2A
,
0xAA
,
0x6A
,
0xEA
,
0x1A
,
0x9A
,
0x5A
,
0xDA
,
0x3A
,
0xBA
,
0x7A
,
0xFA
,
0x06
,
0x86
,
0x46
,
0xC6
,
0x26
,
0xA6
,
0x66
,
0xE6
,
0x16
,
0x96
,
0x56
,
0xD6
,
0x36
,
0xB6
,
0x76
,
0xF6
,
0x0E
,
0x8E
,
0x4E
,
0xCE
,
0x2E
,
0xAE
,
0x6E
,
0xEE
,
0x1E
,
0x9E
,
0x5E
,
0xDE
,
0x3E
,
0xBE
,
0x7E
,
0xFE
,
0x01
,
0x81
,
0x41
,
0xC1
,
0x21
,
0xA1
,
0x61
,
0xE1
,
0x11
,
0x91
,
0x51
,
0xD1
,
0x31
,
0xB1
,
0x71
,
0xF1
,
0x09
,
0x89
,
0x49
,
0xC9
,
0x29
,
0xA9
,
0x69
,
0xE9
,
0x19
,
0x99
,
0x59
,
0xD9
,
0x39
,
0xB9
,
0x79
,
0xF9
,
0x05
,
0x85
,
0x45
,
0xC5
,
0x25
,
0xA5
,
0x65
,
0xE5
,
0x15
,
0x95
,
0x55
,
0xD5
,
0x35
,
0xB5
,
0x75
,
0xF5
,
0x0D
,
0x8D
,
0x4D
,
0xCD
,
0x2D
,
0xAD
,
0x6D
,
0xED
,
0x1D
,
0x9D
,
0x5D
,
0xDD
,
0x3D
,
0xBD
,
0x7D
,
0xFD
,
0x03
,
0x83
,
0x43
,
0xC3
,
0x23
,
0xA3
,
0x63
,
0xE3
,
0x13
,
0x93
,
0x53
,
0xD3
,
0x33
,
0xB3
,
0x73
,
0xF3
,
0x0B
,
0x8B
,
0x4B
,
0xCB
,
0x2B
,
0xAB
,
0x6B
,
0xEB
,
0x1B
,
0x9B
,
0x5B
,
0xDB
,
0x3B
,
0xBB
,
0x7B
,
0xFB
,
0x07
,
0x87
,
0x47
,
0xC7
,
0x27
,
0xA7
,
0x67
,
0xE7
,
0x17
,
0x97
,
0x57
,
0xD7
,
0x37
,
0xB7
,
0x77
,
0xF7
,
0x0F
,
0x8F
,
0x4F
,
0xCF
,
0x2F
,
0xAF
,
0x6F
,
0xEF
,
0x1F
,
0x9F
,
0x5F
,
0xDF
,
0x3F
,
0xBF
,
0x7F
,
0xFF
};
static
inline
uint32_t
bitfn_swap32
(
uint32_t
a
)
{
return
(
BitReverseTable256
[
a
&
0xff
]
<<
24
)
|
(
BitReverseTable256
[(
a
>>
8
)
&
0xff
]
<<
16
)
|
(
BitReverseTable256
[(
a
>>
16
)
&
0xff
]
<<
8
)
|
(
BitReverseTable256
[(
a
>>
24
)
&
0xff
]);
}
static
inline
uint64_t
bitfn_swap64
(
uint64_t
a
)
{
return
((
uint64_t
)
bitfn_swap32
((
uint32_t
)
(
a
>>
32
)))
|
(((
uint64_t
)
bitfn_swap32
((
uint32_t
)
a
))
<<
32
);
}
#if defined(__MINGW32__) || defined(_WIN32)
#if defined(__MINGW32__) || defined(_WIN32)
# define LITTLE_ENDIAN 1234
# define LITTLE_ENDIAN 1234
# define BYTE_ORDER LITTLE_ENDIAN
# define BYTE_ORDER LITTLE_ENDIAN
...
@@ -53,22 +21,52 @@ static inline uint64_t bitfn_swap64(uint64_t a) {
...
@@ -53,22 +21,52 @@ static inline uint64_t bitfn_swap64(uint64_t a) {
# define BIG_ENDIAN 1234
# define BIG_ENDIAN 1234
# define BYTE_ORDER BIG_ENDIAN
# define BYTE_ORDER BIG_ENDIAN
#else
#else
# include <endian.h>
# include <endian.h>
#endif
#if defined(_WIN32)
#include <stdlib.h>
#define ethash_swap_u32(input_) _byteswap_ulong(input_)
#define ethash_swap_u64(input_) _byteswap_uint64(input_)
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define ethash_swap_u32(input_) OSSwapInt32(input_)
#define ethash_swap_u64(input_) OSSwapInt64(input_)
#else // posix
#include <byteswap.h>
#define ethash_swap_u32(input_) __bswap_32(input_)
#define ethash_swap_u64(input_) __bswap_64(input_)
#endif
#endif
#if LITTLE_ENDIAN == BYTE_ORDER
#if LITTLE_ENDIAN == BYTE_ORDER
#define fix_endian32(x) (x)
#define fix_endian32(dst_ ,src_) dst_ = src_
#define fix_endian64(x) (x)
#define fix_endian32_same(val_)
#define fix_endian64(dst_, src_) dst_ = src_
#define fix_endian64_same(val_)
#define fix_endian_arr32(arr_, size_)
#define fix_endian_arr64(arr_, size_)
#elif BIG_ENDIAN == BYTE_ORDER
#elif BIG_ENDIAN == BYTE_ORDER
#define fix_endian32(x) bitfn_swap32(x)
#define fix_endian32(dst_, src_) dst_ = ethash_swap_u32(src_)
#define fix_endian64(x) bitfn_swap64(x)
#define fix_endian32_same(val_) val_ = ethash_swap_u32(val_)
#define fix_endian64(dst_, src_) dst_ = ethash_swap_u64(src_
#define fix_endian64_same(val_) val_ = ethash_swap_u64(val_)
#define fix_endian_arr32(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u32(arr_[i_]); \
} \
while (0)
#define fix_endian_arr64(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u64(arr_[i_]); \
} \
while (0) \
#else
#else
# error "endian not supported"
# error "endian not supported"
#endif // BYTE_ORDER
#endif // BYTE_ORDER
\ No newline at end of file
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h
浏览文件 @
50659f4b
...
@@ -26,124 +26,121 @@
...
@@ -26,124 +26,121 @@
#include <stddef.h>
#include <stddef.h>
#include "compiler.h"
#include "compiler.h"
#define REVISION 23
#define ETHASH_REVISION 23
#define DATASET_BYTES_INIT 1073741824U // 2**30
#define ETHASH_DATASET_BYTES_INIT 1073741824U // 2**30
#define DATASET_BYTES_GROWTH 8388608U // 2**23
#define ETHASH_DATASET_BYTES_GROWTH 8388608U // 2**23
#define CACHE_BYTES_INIT 1073741824U // 2**24
#define ETHASH_CACHE_BYTES_INIT 1073741824U // 2**24
#define CACHE_BYTES_GROWTH 131072U // 2**17
#define ETHASH_CACHE_BYTES_GROWTH 131072U // 2**17
#define EPOCH_LENGTH 30000U
#define ETHASH_EPOCH_LENGTH 30000U
#define MIX_BYTES 128
#define ETHASH_MIX_BYTES 128
#define HASH_BYTES 64
#define ETHASH_HASH_BYTES 64
#define DATASET_PARENTS 256
#define ETHASH_DATASET_PARENTS 256
#define CACHE_ROUNDS 3
#define ETHASH_CACHE_ROUNDS 3
#define ACCESSES 64
#define ETHASH_ACCESSES 64
#define ETHASH_DAG_MAGIC_NUM_SIZE 8
#define ETHASH_DAG_MAGIC_NUM 0xFEE1DEADBADDCAFE
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
ethash_params
{
/// Type of a seedhash/blockhash e.t.c.
uint64_t
full_size
;
// Size of full data set (in bytes, multiple of mix size (128)).
typedef
struct
ethash_h256
{
uint8_t
b
[
32
];
}
ethash_h256_t
;
uint64_t
cache_size
;
// Size of compute cache (in bytes, multiple of node size (64)).
}
ethash_params
;
/// Type of a blockhash
// convenience macro to statically initialize an h256_t
typedef
struct
ethash_blockhash
{
uint8_t
b
[
32
];
}
ethash_blockhash_t
;
// usage:
static
inline
uint8_t
ethash_blockhash_get
(
ethash_blockhash_t
const
*
hash
,
unsigned
int
i
)
// ethash_h256_t a = ethash_h256_static_init(1, 2, 3, ... )
{
// have to provide all 32 values. If you don't provide all the rest
return
hash
->
b
[
i
];
// will simply be unitialized (not guranteed to be 0)
}
#define ethash_h256_static_init(...) \
{ {__VA_ARGS__} }
static
inline
void
ethash_blockhash_set
(
ethash_blockhash_t
*
hash
,
unsigned
int
i
,
uint8_t
v
)
struct
ethash_light
;
{
typedef
struct
ethash_light
*
ethash_light_t
;
hash
->
b
[
i
]
=
v
;
struct
ethash_full
;
}
typedef
struct
ethash_full
*
ethash_full_t
;
typedef
int
(
*
ethash_callback_t
)(
unsigned
);
static
inline
void
ethash_blockhash_reset
(
ethash_blockhash_t
*
hash
)
{
memset
(
hash
,
0
,
32
);
}
typedef
struct
ethash_return_value
{
typedef
struct
ethash_return_value
{
ethash_blockhash
_t
result
;
ethash_h256
_t
result
;
ethash_blockhash
_t
mix_hash
;
ethash_h256
_t
mix_hash
;
}
ethash_return_value
;
bool
success
;
}
ethash_return_value_t
;
uint64_t
ethash_get_datasize
(
const
uint32_t
block_number
);
uint64_t
ethash_get_cachesize
(
const
uint32_t
block_number
);
/**
* Allocate and initialize a new ethash_light handler
// initialize the parameters
*
static
inline
void
ethash_params_init
(
ethash_params
*
params
,
const
uint32_t
block_number
)
{
* @param block_number The block number for which to create the handler
params
->
full_size
=
ethash_get_datasize
(
block_number
);
* @return Newly allocated ethash_light handler or NULL in case of
params
->
cache_size
=
ethash_get_cachesize
(
block_number
);
* ERRNOMEM or invalid parameters used for @ref ethash_compute_cache_nodes()
}
*/
ethash_light_t
ethash_light_new
(
uint64_t
block_number
);
typedef
struct
ethash_cache
{
/**
void
*
mem
;
* Frees a previously allocated ethash_light handler
}
ethash_cache
;
* @param light The light handler to free
*/
void
ethash_
mkcache
(
ethash_cache
*
cache
,
ethash_params
const
*
params
,
ethash_blockhash_t
const
*
seed
);
void
ethash_
light_delete
(
ethash_light_t
light
);
void
ethash_compute_full_data
(
void
*
mem
,
ethash_params
const
*
params
,
ethash_cache
const
*
cache
);
/**
void
ethash_full
(
ethash_return_value
*
ret
,
* Calculate the light client data
void
const
*
full_mem
,
*
ethash_params
const
*
params
,
* @param light The light client handler
ethash_blockhash_t
const
*
header_hash
,
* @param header_hash The header hash to pack into the mix
const
uint64_t
nonce
);
* @param nonce The nonce to pack into the mix
void
ethash_light
(
ethash_return_value
*
ret
,
* @return an object of ethash_return_value_t holding the return values
ethash_cache
const
*
cache
,
*/
ethash_params
const
*
params
,
ethash_return_value_t
ethash_light_compute
(
ethash_blockhash_t
const
*
header_hash
,
ethash_light_t
light
,
const
uint64_t
nonce
);
ethash_h256_t
const
header_hash
,
void
ethash_get_seedhash
(
ethash_blockhash_t
*
seedhash
,
const
uint32_t
block_number
);
uint64_t
nonce
);
static
inline
void
ethash_prep_light
(
void
*
cache
,
ethash_params
const
*
params
,
ethash_blockhash_t
const
*
seed
)
{
/**
ethash_cache
c
;
* Allocate and initialize a new ethash_full handler
c
.
mem
=
cache
;
*
ethash_mkcache
(
&
c
,
params
,
seed
);
* @param light The light handler containing the cache.
}
* @param callback A callback function with signature of @ref ethash_callback_t
* It accepts an unsigned with which a progress of DAG calculation
static
inline
void
ethash_compute_light
(
ethash_return_value
*
ret
,
void
const
*
cache
,
ethash_params
const
*
params
,
ethash_blockhash_t
const
*
header_hash
,
const
uint64_t
nonce
)
* can be displayed. If all goes well the callback should return 0.
{
* If a non-zero value is returned then DAG generation will stop.
ethash_cache
c
;
* Be advised. A progress value of 100 means that DAG creation is
c
.
mem
=
(
void
*
)
cache
;
* almost complete and that this function will soon return succesfully.
ethash_light
(
ret
,
&
c
,
params
,
header_hash
,
nonce
);
* It does not mean that the function has already had a succesfull return.
}
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
static
inline
void
ethash_prep_full
(
void
*
full
,
ethash_params
const
*
params
,
void
const
*
cache
)
*/
{
ethash_full_t
ethash_full_new
(
ethash_light_t
light
,
ethash_callback_t
callback
);
ethash_cache
c
;
c
.
mem
=
(
void
*
)
cache
;
/**
ethash_compute_full_data
(
full
,
params
,
&
c
);
* Frees a previously allocated ethash_full handler
}
* @param full The light handler to free
*/
static
inline
void
ethash_compute_full
(
ethash_return_value
*
ret
,
void
ethash_full_delete
(
ethash_full_t
full
);
void
const
*
full
,
/**
ethash_params
const
*
params
,
* Calculate the full client data
ethash_blockhash_t
const
*
header_hash
,
*
const
uint64_t
nonce
)
* @param full The full client handler
{
* @param header_hash The header hash to pack into the mix
ethash_full
(
ret
,
full
,
params
,
header_hash
,
nonce
);
* @param nonce The nonce to pack into the mix
}
* @return An object of ethash_return_value to hold the return value
*/
// Returns if hash is less than or equal to difficulty
ethash_return_value_t
ethash_full_compute
(
static
inline
int
ethash_check_difficulty
(
ethash_blockhash_t
const
*
hash
,
ethash_full_t
full
,
ethash_blockhash_t
const
*
difficulty
)
ethash_h256_t
const
header_hash
,
{
uint64_t
nonce
// Difficulty is big endian
);
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
/**
if
(
ethash_blockhash_get
(
hash
,
i
)
==
ethash_blockhash_get
(
difficulty
,
i
))
{
* Get a pointer to the full DAG data
continue
;
*/
}
void
const
*
ethash_full_dag
(
ethash_full_t
full
);
return
ethash_blockhash_get
(
hash
,
i
)
<
ethash_blockhash_get
(
difficulty
,
i
);
/**
}
* Get the size of the DAG data
return
1
;
*/
}
uint64_t
ethash_full_dag_size
(
ethash_full_t
full
);
int
ethash_quick_check_difficulty
(
ethash_blockhash_t
const
*
header_hash
,
/**
const
uint64_t
nonce
,
* Calculate the seedhash for a given block number
ethash_blockhash_t
const
*
mix_hash
,
*/
ethash_blockhash_t
const
*
difficulty
);
ethash_h256_t
ethash_get_seedhash
(
uint64_t
block_number
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
浏览文件 @
50659f4b
...
@@ -29,10 +29,11 @@ extern "C" {
...
@@ -29,10 +29,11 @@ extern "C" {
#define FNV_PRIME 0x01000193
#define FNV_PRIME 0x01000193
static
inline
uint32_t
fnv_hash
(
const
uint32_t
x
,
const
uint32_t
y
)
{
static
inline
uint32_t
fnv_hash
(
uint32_t
const
x
,
uint32_t
const
y
)
return
x
*
FNV_PRIME
^
y
;
{
return
x
*
FNV_PRIME
^
y
;
}
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
\ No newline at end of file
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h
浏览文件 @
50659f4b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "compiler.h"
#include "compiler.h"
#include "endian.h"
#include "endian.h"
#include "ethash.h"
#include "ethash.h"
#include <stdio.h>
#define ENABLE_SSE 0
#define ENABLE_SSE 0
...
@@ -15,14 +16,14 @@ extern "C" {
...
@@ -15,14 +16,14 @@ extern "C" {
// compile time settings
// compile time settings
#define NODE_WORDS (64/4)
#define NODE_WORDS (64/4)
#define MIX_WORDS (MIX_BYTES/4)
#define MIX_WORDS (
ETHASH_
MIX_BYTES/4)
#define MIX_NODES (MIX_WORDS / NODE_WORDS)
#define MIX_NODES (MIX_WORDS / NODE_WORDS)
#include <stdint.h>
#include <stdint.h>
typedef
union
node
{
typedef
union
node
{
uint8_t
bytes
[
NODE_WORDS
*
4
];
uint8_t
bytes
[
NODE_WORDS
*
4
];
uint32_t
words
[
NODE_WORDS
];
uint32_t
words
[
NODE_WORDS
];
uint64_t
double_words
[
NODE_WORDS
/
2
];
uint64_t
double_words
[
NODE_WORDS
/
2
];
#if defined(_M_X64) && ENABLE_SSE
#if defined(_M_X64) && ENABLE_SSE
__m128i
xmm
[
NODE_WORDS
/
4
];
__m128i
xmm
[
NODE_WORDS
/
4
];
...
@@ -30,15 +31,139 @@ typedef union node {
...
@@ -30,15 +31,139 @@ typedef union node {
}
node
;
}
node
;
void
ethash_calculate_dag_item
(
node
*
const
ret
,
static
inline
uint8_t
ethash_h256_get
(
ethash_h256_t
const
*
hash
,
unsigned
int
i
)
const
unsigned
node_index
,
{
ethash_params
const
*
params
,
return
hash
->
b
[
i
];
ethash_cache
const
*
cache
);
}
static
inline
void
ethash_h256_set
(
ethash_h256_t
*
hash
,
unsigned
int
i
,
uint8_t
v
)
{
hash
->
b
[
i
]
=
v
;
}
static
inline
void
ethash_h256_reset
(
ethash_h256_t
*
hash
)
{
memset
(
hash
,
0
,
32
);
}
// Returns if hash is less than or equal to difficulty
static
inline
int
ethash_check_difficulty
(
ethash_h256_t
const
*
hash
,
ethash_h256_t
const
*
difficulty
)
{
// Difficulty is big endian
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
if
(
ethash_h256_get
(
hash
,
i
)
==
ethash_h256_get
(
difficulty
,
i
))
{
continue
;
}
return
ethash_h256_get
(
hash
,
i
)
<
ethash_h256_get
(
difficulty
,
i
);
}
return
1
;
}
int
ethash_quick_check_difficulty
(
ethash_h256_t
const
*
header_hash
,
uint64_t
const
nonce
,
ethash_h256_t
const
*
mix_hash
,
ethash_h256_t
const
*
difficulty
);
struct
ethash_light
{
void
*
cache
;
uint64_t
cache_size
;
uint64_t
block_number
;
};
/**
* 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
* @return The resulting hash.
*/
ethash_return_value_t
ethash_light_compute_internal
(
ethash_light_t
light
,
uint64_t
full_size
,
ethash_h256_t
const
header_hash
,
uint64_t
nonce
);
struct
ethash_full
{
FILE
*
file
;
uint64_t
file_size
;
node
*
data
;
};
/**
* Allocate and initialize a new ethash_full handler. Internal version.
*
* @param dirname The directory in which to put the DAG file.
* @param seedhash The seed hash of the block. Used in the DAG file naming.
* @param full_size The size of the full data in bytes.
* @param cache A cache object to use that was allocated with @ref ethash_cache_new().
* Iff this function succeeds the ethash_full_t will take memory
* memory ownership of the cache and free it at deletion. If
* not then the user still has to handle freeing of the cache himself.
* @param callback A callback function with signature of @ref ethash_callback_t
* It accepts an unsigned with which a progress of DAG calculation
* can be displayed. If all goes well the callback should return 0.
* If a non-zero value is returned then DAG generation will stop.
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
*/
ethash_full_t
ethash_full_new_internal
(
char
const
*
dirname
,
ethash_h256_t
const
seed_hash
,
uint64_t
full_size
,
ethash_light_t
const
light
,
ethash_callback_t
callback
);
void
ethash_calculate_dag_item
(
node
*
const
ret
,
uint32_t
node_index
,
ethash_light_t
const
cache
);
void
ethash_quick_hash
(
ethash_h256_t
*
return_hash
,
ethash_h256_t
const
*
header_hash
,
const
uint64_t
nonce
,
ethash_h256_t
const
*
mix_hash
);
uint64_t
ethash_get_datasize
(
uint64_t
const
block_number
);
uint64_t
ethash_get_cachesize
(
uint64_t
const
block_number
);
void
ethash_quick_hash
(
ethash_blockhash_t
*
return_hash
,
/**
ethash_blockhash_t
const
*
header_hash
,
* Compute the memory data for a full node's memory
const
uint64_t
nonce
,
*
ethash_blockhash_t
const
*
mix_hash
);
* @param mem A pointer to an ethash full's memory
* @param full_size The size of the full data in bytes
* @param cache A cache object to use in the calculation
* @param callback The callback function. Check @ref ethash_full_new() for details.
* @return true if all went fine and false for invalid parameters
*/
bool
ethash_compute_full_data
(
void
*
mem
,
uint64_t
full_size
,
ethash_light_t
const
light
,
ethash_callback_t
callback
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.c
浏览文件 @
50659f4b
...
@@ -22,68 +22,81 @@
...
@@ -22,68 +22,81 @@
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
// silly macro to save some typing
enum
ethash_io_rc
ethash_io_prepare
(
#define PASS_ARR(c_) (c_), sizeof(c_)
char
const
*
dirname
,
ethash_h256_t
const
seedhash
,
static
bool
ethash_io_write_file
(
char
const
*
dirname
,
FILE
**
output_file
,
char
const
*
filename
,
uint64_t
file_size
,
size_t
filename_length
,
bool
force_create
void
const
*
data
,
)
size_t
data_size
)
{
bool
ret
=
false
;
char
*
fullname
=
ethash_io_create_filename
(
dirname
,
filename
,
filename_length
);
if
(
!
fullname
)
{
return
false
;
}
FILE
*
f
=
fopen
(
fullname
,
"wb"
);
if
(
!
f
)
{
goto
free_name
;
}
if
(
data_size
!=
fwrite
(
data
,
1
,
data_size
,
f
))
{
goto
close
;
}
ret
=
true
;
close:
fclose
(
f
);
free_name:
free
(
fullname
);
return
ret
;
}
bool
ethash_io_write
(
char
const
*
dirname
,
ethash_params
const
*
params
,
ethash_blockhash_t
seedhash
,
void
const
*
cache
,
uint8_t
**
data
,
uint64_t
*
data_size
)
{
{
char
info_buffer
[
DAG_MEMO_BYTESIZE
];
char
mutable_name
[
DAG_MUTABLE_NAME_MAX_SIZE
];
// allocate the bytes
enum
ethash_io_rc
ret
=
ETHASH_IO_FAIL
;
uint8_t
*
temp_data_ptr
=
malloc
((
size_t
)
params
->
full_size
);
if
(
!
temp_data_ptr
)
{
goto
end
;
}
ethash_compute_full_data
(
temp_data_ptr
,
params
,
cache
);
if
(
!
ethash_io_write_file
(
dirname
,
PASS_ARR
(
DAG_FILE_NAME
),
temp_data_ptr
,
(
size_t
)
params
->
full_size
))
{
// assert directory exists
goto
fail_free
;
if
(
!
ethash_mkdir
(
dirname
))
{
}
goto
end
;
}
ethash_io_serialize_info
(
REVISION
,
seedhash
,
info_buffer
);
ethash_io_mutable_name
(
ETHASH_REVISION
,
&
seedhash
,
mutable_name
);
if
(
!
ethash_io_write_file
(
dirname
,
PASS_ARR
(
DAG_MEMO_NAME
),
info_buffer
,
DAG_MEMO_BYTESIZE
))
{
char
*
tmpfile
=
ethash_io_create_filename
(
dirname
,
mutable_name
,
strlen
(
mutable_name
));
goto
fail_free
;
if
(
!
tmpfile
)
{
}
goto
end
;
}
*
data
=
temp_data_ptr
;
FILE
*
f
;
*
data_size
=
params
->
full_size
;
if
(
!
force_create
)
{
return
true
;
// try to open the file
f
=
ethash_fopen
(
tmpfile
,
"rb+"
);
if
(
f
)
{
size_t
found_size
;
if
(
!
ethash_file_size
(
f
,
&
found_size
))
{
fclose
(
f
);
goto
free_memo
;
}
if
(
file_size
!=
found_size
-
ETHASH_DAG_MAGIC_NUM_SIZE
)
{
fclose
(
f
);
ret
=
ETHASH_IO_MEMO_SIZE_MISMATCH
;
goto
free_memo
;
}
// compare the magic number, no need to care about endianess since it's local
uint64_t
magic_num
;
if
(
fread
(
&
magic_num
,
ETHASH_DAG_MAGIC_NUM_SIZE
,
1
,
f
)
!=
1
)
{
// I/O error
fclose
(
f
);
ret
=
ETHASH_IO_MEMO_SIZE_MISMATCH
;
goto
free_memo
;
}
if
(
magic_num
!=
ETHASH_DAG_MAGIC_NUM
)
{
fclose
(
f
);
ret
=
ETHASH_IO_MEMO_SIZE_MISMATCH
;
goto
free_memo
;
}
ret
=
ETHASH_IO_MEMO_MATCH
;
goto
set_file
;
}
}
// file does not exist, will need to be created
f
=
ethash_fopen
(
tmpfile
,
"wb+"
);
if
(
!
f
)
{
goto
free_memo
;
}
// make sure it's of the proper size
if
(
fseek
(
f
,
(
long
int
)(
file_size
+
ETHASH_DAG_MAGIC_NUM_SIZE
-
1
),
SEEK_SET
)
!=
0
)
{
fclose
(
f
);
goto
free_memo
;
}
fputc
(
'\n'
,
f
);
fflush
(
f
);
ret
=
ETHASH_IO_MEMO_MISMATCH
;
goto
set_file
;
fail_free:
ret
=
ETHASH_IO_MEMO_MATCH
;
free
(
temp_data_ptr
);
set_file:
*
output_file
=
f
;
free_memo:
free
(
tmpfile
);
end:
end:
return
false
;
return
ret
;
}
}
#undef PASS_ARR
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io.h
浏览文件 @
50659f4b
...
@@ -22,93 +22,162 @@
...
@@ -22,93 +22,162 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#include "endian.h"
#include "ethash.h"
#include "ethash.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
// Maximum size for mutable part of DAG file name
static
const
char
DAG_FILE_NAME
[]
=
"full"
;
// 10 is for maximum number of digits of a uint32_t (for REVISION)
static
const
char
DAG_MEMO_NAME
[]
=
"full.info"
;
// 1 is for _ and 16 is for the first 16 hex digits for first 8 bytes of
//
MSVC thinks that "static const unsigned int" is not a compile time variable. Sorry for the #define :(
//
the seedhash and last 1 is for the null terminating character
#define DAG_MEMO_BYTESIZE 36
// Reference: https://github.com/ethereum/wiki/wiki/Ethash-DAG
#define DAG_MUTABLE_NAME_MAX_SIZE (10 + 1 + 16 + 1)
/// Possible return values of @see ethash_io_prepare
/// Possible return values of @see ethash_io_prepare
enum
ethash_io_rc
{
enum
ethash_io_rc
{
ETHASH_IO_FAIL
=
0
,
///< There has been an IO failure
ETHASH_IO_FAIL
=
0
,
///< There has been an IO failure
ETHASH_IO_MEMO_MISMATCH
,
///< Memo file either did not exist or there was content mismatch
ETHASH_IO_MEMO_SIZE_MISMATCH
,
///< DAG with revision/hash match, but file size was wrong.
ETHASH_IO_MEMO_MATCH
,
///< Memo file existed and contents matched. No need to do anything
ETHASH_IO_MEMO_MISMATCH
,
///< The DAG file did not exist or there was revision/hash mismatch
ETHASH_IO_MEMO_MATCH
,
///< DAG file existed and revision/hash matched. No need to do anything
};
};
// small hack for windows. I don't feel I should use va_args and forward just
// to have this one function properly cross-platform abstracted
#if defined(_WIN32)
#define snprintf(...) sprintf_s(__VA_ARGS__)
#endif
/**
/**
* Prepares io for ethash
* Prepares io for ethash
*
*
* Create the DAG directory if it does not exist, and check if the memo file matches.
* Create the DAG directory and the DAG file if they don't exist.
* If it does not match then it's deleted to pave the way for @ref ethash_io_write()
*
*
* @param dirname A null terminated c-string of the path of the ethash
* @param[in] dirname A null terminated c-string of the path of the ethash
* data directory. If it does not exist it's created.
* data directory. If it does not exist it's created.
* @param seedhash The seedhash of the current block number
* @param[in] seedhash The seedhash of the current block number, used in the
* @return For possible return values @see enum ethash_io_rc
* naming of the file as can be seen from the spec at:
* https://github.com/ethereum/wiki/wiki/Ethash-DAG
* @param[out] output_file If there was no failure then this will point to an open
* file descriptor. User is responsible for closing it.
* In the case of memo match then the file is open on read
* mode, while on the case of mismatch a new file is created
* on write mode
* @param[in] file_size The size that the DAG file should have on disk
* @param[out] force_create If true then there is no check to see if the file
* already exists
* @return For possible return values @see enum ethash_io_rc
*/
*/
enum
ethash_io_rc
ethash_io_prepare
(
char
const
*
dirname
,
ethash_blockhash_t
seedhash
);
enum
ethash_io_rc
ethash_io_prepare
(
char
const
*
dirname
,
ethash_h256_t
const
seedhash
,
FILE
**
output_file
,
uint64_t
file_size
,
bool
force_create
);
/**
/**
*
Fully computes data and writes it to the file on disk
.
*
An fopen wrapper for no-warnings crossplatform fopen
.
*
*
* This function should be called after @see ethash_io_prepare() and only if
* Msvc compiler considers fopen to be insecure and suggests to use their
* its return value is @c ETHASH_IO_MEMO_MISMATCH. Will write both the full data
* alternative. This is a wrapper for this alternative. Another way is to
* and the memo file.
* #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does
* not sound like a good idea.
*
*
* @param[in] dirname A null terminated c-string of the path of the ethash
* @param file_name The path to the file to open
* data directory. Has to exist.
* @param mode Opening mode. Check fopen()
* @param[in] params An ethash_params object containing the full size
* @return The FILE* or NULL in failure
* and the cache size
* @param[in] seedhash The seedhash of the current block number
* @param[in] cache The cache data. Would have usually been calulated by
* @see ethash_prep_light().
* @param[out] data Pass a pointer to uint8_t by reference here. If the
* function is succesfull then this point to the allocated
* data calculated by @see ethash_prep_full(). Memory
* ownership is transfered to the callee. Remember that
* you eventually need to free this with a call to free().
* @param[out] data_size Pass a uint64_t by value. If the function is succesfull
* then this will contain the number of bytes allocated
* for @a data.
* @return True for success and false in case of failure.
*/
*/
bool
ethash_io_write
(
char
const
*
dirname
,
FILE
*
ethash_fopen
(
char
const
*
file_name
,
char
const
*
mode
);
ethash_params
const
*
params
,
ethash_blockhash_t
seedhash
,
void
const
*
cache
,
uint8_t
**
data
,
uint64_t
*
data_size
);
static
inline
void
ethash_io_serialize_info
(
uint32_t
revision
,
/**
ethash_blockhash_t
seed_hash
,
* An strncat wrapper for no-warnings crossplatform strncat.
char
*
output
)
*
{
* Msvc compiler considers strncat to be insecure and suggests to use their
// if .info is only consumed locally we don't really care about endianess
* alternative. This is a wrapper for this alternative. Another way is to
memcpy
(
output
,
&
revision
,
4
);
* #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does
memcpy
(
output
+
4
,
&
seed_hash
,
32
);
* not sound like a good idea.
}
*
* @param des Destination buffer
* @param dest_size Maximum size of the destination buffer. This is the
* extra argument for the MSVC secure strncat
* @param src Souce buffer
* @param count Number of bytes to copy from source
* @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
,
char
const
*
src
,
size_t
count
);
static
inline
char
*
ethash_io_create_filename
(
char
const
*
dirname
,
/**
char
const
*
filename
,
* A cross-platform mkdir wrapper to create a directory or assert it's there
size_t
filename_length
)
*
{
* @param dirname The full path of the directory to create
// in C the cast is not needed, but a C++ compiler will complain for invalid conversion
* @return true if the directory was created or if it already
char
*
name
=
(
char
*
)
malloc
(
strlen
(
dirname
)
+
filename_length
);
* existed
if
(
!
name
)
{
*/
return
NULL
;
bool
ethash_mkdir
(
char
const
*
dirname
);
}
name
[
0
]
=
'\0'
;
/**
strcat
(
name
,
dirname
);
* Get a file's size
strcat
(
name
,
filename
);
*
return
name
;
* @param[in] f The open file stream whose size to get
}
* @param[out] size Pass a size_t by reference to contain the file size
* @return true in success and false if there was a failure
*/
bool
ethash_file_size
(
FILE
*
f
,
size_t
*
ret_size
);
/**
* Get a file descriptor number from a FILE stream
*
* @param f The file stream whose fd to get
* @return Platform specific fd handler
*/
int
ethash_fileno
(
FILE
*
f
);
/**
* Create the filename for the DAG.
*
* @param dirname The directory name in which the DAG file should reside
* If it does not end with a directory separator it is appended.
* @param filename The actual name of the file
* @param filename_length The length of the filename in bytes
* @return A char* containing the full name. User must deallocate.
*/
char
*
ethash_io_create_filename
(
char
const
*
dirname
,
char
const
*
filename
,
size_t
filename_length
);
/**
* Gets the default directory name for the DAG depending on the system
*
* The spec defining this directory is here: https://github.com/ethereum/wiki/wiki/Ethash-DAG
*
* @param[out] strbuf A string buffer of sufficient size to keep the
* null termninated string of the directory name
* @param[in] buffsize Size of @a strbuf in bytes
* @return true for success and false otherwise
*/
bool
ethash_get_default_dirname
(
char
*
strbuf
,
size_t
buffsize
);
static
inline
bool
ethash_io_mutable_name
(
uint32_t
revision
,
ethash_h256_t
const
*
seed_hash
,
char
*
output
)
{
uint64_t
hash
=
*
((
uint64_t
*
)
seed_hash
);
#if LITTLE_ENDIAN == BYTE_ORDER
hash
=
ethash_swap_u64
(
hash
);
#endif
return
snprintf
(
output
,
DAG_MUTABLE_NAME_MAX_SIZE
,
"%u_%016"
PRIx64
,
revision
,
hash
)
>=
0
;
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_posix.c
浏览文件 @
50659f4b
...
@@ -27,50 +27,76 @@
...
@@ -27,50 +27,76 @@
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
enum
ethash_io_rc
ethash_io_prepare
(
char
const
*
dirname
,
ethash_blockhash_t
seedhash
)
FILE
*
ethash_fopen
(
char
const
*
file_name
,
char
const
*
mode
)
{
{
char
read_buffer
[
DAG_MEMO_BYTESIZE
];
return
fopen
(
file_name
,
mode
);
char
expect_buffer
[
DAG_MEMO_BYTESIZE
];
}
enum
ethash_io_rc
ret
=
ETHASH_IO_FAIL
;
// assert directory exists, full owner permissions and read/search for others
char
*
ethash_strncat
(
char
*
dest
,
size_t
dest_size
,
char
const
*
src
,
size_t
count
)
int
rc
=
mkdir
(
dirname
,
S_IRWXU
|
S_IRWXG
|
S_IROTH
|
S_IXOTH
);
{
if
(
rc
==
-
1
&&
errno
!=
EEXIST
)
{
return
strlen
(
dest
)
+
count
+
1
<=
dest_size
?
strncat
(
dest
,
src
,
count
)
:
NULL
;
goto
end
;
}
}
char
*
memofile
=
ethash_io_create_filename
(
dirname
,
DAG_MEMO_NAME
,
sizeof
(
DAG_MEMO_NAME
));
bool
ethash_mkdir
(
char
const
*
dirname
)
if
(
!
memofile
)
{
{
goto
end
;
int
rc
=
mkdir
(
dirname
,
S_IRWXU
|
S_IRWXG
|
S_IROTH
|
S_IXOTH
);
}
return
rc
!=
-
1
||
errno
==
EEXIST
;
}
// try to open memo file
int
ethash_fileno
(
FILE
*
f
)
FILE
*
f
=
fopen
(
memofile
,
"rb"
);
{
if
(
!
f
)
{
return
fileno
(
f
);
// file does not exist, so no checking happens. All is fine.
}
ret
=
ETHASH_IO_MEMO_MISMATCH
;
goto
free_memo
;
}
if
(
fread
(
read_buffer
,
1
,
DAG_MEMO_BYTESIZE
,
f
)
!=
DAG_MEMO_BYTESIZE
)
{
char
*
ethash_io_create_filename
(
goto
close
;
char
const
*
dirname
,
}
char
const
*
filename
,
size_t
filename_length
)
{
size_t
dirlen
=
strlen
(
dirname
);
size_t
dest_size
=
dirlen
+
filename_length
+
1
;
if
(
dirname
[
dirlen
]
!=
'/'
)
{
dest_size
+=
1
;
}
char
*
name
=
malloc
(
dest_size
);
if
(
!
name
)
{
return
NULL
;
}
ethash_io_serialize_info
(
REVISION
,
seedhash
,
expect_buffer
)
;
name
[
0
]
=
'\0'
;
if
(
memcmp
(
read_buffer
,
expect_buffer
,
DAG_MEMO_BYTESIZE
)
!=
0
)
{
ethash_strncat
(
name
,
dest_size
,
dirname
,
dirlen
);
// we have different memo contents so delete the memo file
if
(
dirname
[
dirlen
]
!=
'/'
)
{
if
(
unlink
(
memofile
)
!=
0
)
{
ethash_strncat
(
name
,
dest_size
,
"/"
,
1
);
goto
close
;
}
}
ethash_strncat
(
name
,
dest_size
,
filename
,
filename_length
);
ret
=
ETHASH_IO_MEMO_MISMATCH
;
return
name
;
}
}
ret
=
ETHASH_IO_MEMO_MATCH
;
bool
ethash_file_size
(
FILE
*
f
,
size_t
*
ret_size
)
{
struct
stat
st
;
int
fd
;
if
((
fd
=
fileno
(
f
))
==
-
1
||
fstat
(
fd
,
&
st
)
!=
0
)
{
return
false
;
}
*
ret_size
=
st
.
st_size
;
return
true
;
}
close:
bool
ethash_get_default_dirname
(
char
*
strbuf
,
size_t
buffsize
)
fclose
(
f
);
{
free_memo:
static
const
char
dir_suffix
[]
=
".ethash/"
;
free
(
memofile
);
strbuf
[
0
]
=
'\0'
;
end:
char
*
home_dir
=
getenv
(
"HOME"
);
return
ret
;
size_t
len
=
strlen
(
home_dir
);
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
home_dir
,
len
))
{
return
false
;
}
if
(
home_dir
[
len
]
!=
'/'
)
{
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
"/"
,
1
))
{
return
false
;
}
}
return
ethash_strncat
(
strbuf
,
buffsize
,
dir_suffix
,
sizeof
(
dir_suffix
));
}
}
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/io_win32.c
浏览文件 @
50659f4b
...
@@ -23,51 +23,78 @@
...
@@ -23,51 +23,78 @@
#include <direct.h>
#include <direct.h>
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <Shlobj.h>
enum
ethash_io_rc
ethash_io_prepare
(
char
const
*
dirname
,
ethash_blockhash_t
seedhash
)
FILE
*
ethash_fopen
(
char
const
*
file_name
,
char
const
*
mode
)
{
{
char
read_buffer
[
DAG_MEMO_BYTESIZE
]
;
FILE
*
f
;
char
expect_buffer
[
DAG_MEMO_BYTESIZE
]
;
return
fopen_s
(
&
f
,
file_name
,
mode
)
==
0
?
f
:
NULL
;
enum
ethash_io_rc
ret
=
ETHASH_IO_FAIL
;
}
// assert directory exists
char
*
ethash_strncat
(
char
*
dest
,
size_t
dest_size
,
char
const
*
src
,
size_t
count
)
int
rc
=
_mkdir
(
dirname
);
{
if
(
rc
==
-
1
&&
errno
!=
EEXIST
)
{
return
strncat_s
(
dest
,
dest_size
,
src
,
count
)
==
0
?
dest
:
NULL
;
goto
end
;
}
}
char
*
memofile
=
ethash_io_create_filename
(
dirname
,
DAG_MEMO_NAME
,
sizeof
(
DAG_MEMO_NAME
));
bool
ethash_mkdir
(
char
const
*
dirname
)
if
(
!
memofile
)
{
{
goto
end
;
int
rc
=
_mkdir
(
dirname
);
}
return
rc
!=
-
1
||
errno
==
EEXIST
;
}
// try to open memo file
int
ethash_fileno
(
FILE
*
f
)
FILE
*
f
=
fopen
(
memofile
,
"rb"
);
{
if
(
!
f
)
{
return
_fileno
(
f
);
// file does not exist, so no checking happens. All is fine.
}
ret
=
ETHASH_IO_MEMO_MISMATCH
;
goto
free_memo
;
}
if
(
fread
(
read_buffer
,
1
,
DAG_MEMO_BYTESIZE
,
f
)
!=
DAG_MEMO_BYTESIZE
)
{
char
*
ethash_io_create_filename
(
goto
close
;
char
const
*
dirname
,
}
char
const
*
filename
,
size_t
filename_length
)
{
size_t
dirlen
=
strlen
(
dirname
);
size_t
dest_size
=
dirlen
+
filename_length
+
1
;
if
(
dirname
[
dirlen
]
!=
'\\'
||
dirname
[
dirlen
]
!=
'/'
)
{
dest_size
+=
1
;
}
char
*
name
=
malloc
(
dest_size
);
if
(
!
name
)
{
return
NULL
;
}
name
[
0
]
=
'\0'
;
ethash_strncat
(
name
,
dest_size
,
dirname
,
dirlen
);
if
(
dirname
[
dirlen
]
!=
'\\'
||
dirname
[
dirlen
]
!=
'/'
)
{
ethash_strncat
(
name
,
dest_size
,
"
\\
"
,
1
);
}
ethash_strncat
(
name
,
dest_size
,
filename
,
filename_length
);
return
name
;
}
ethash_io_serialize_info
(
REVISION
,
seedhash
,
expect_buffer
);
bool
ethash_file_size
(
FILE
*
f
,
size_t
*
ret_size
)
if
(
memcmp
(
read_buffer
,
expect_buffer
,
DAG_MEMO_BYTESIZE
)
!=
0
)
{
{
// we have different memo contents so delete the memo file
struct
_stat
st
;
if
(
_unlink
(
memofile
)
!=
0
)
{
int
fd
;
goto
close
;
if
((
fd
=
_fileno
(
f
))
==
-
1
||
_fstat
(
fd
,
&
st
)
!=
0
)
{
}
return
false
;
ret
=
ETHASH_IO_MEMO_MISMATCH
;
}
}
*
ret_size
=
st
.
st_size
;
return
true
;
}
ret
=
ETHASH_IO_MEMO_MATCH
;
bool
ethash_get_default_dirname
(
char
*
strbuf
,
size_t
buffsize
)
{
static
const
char
dir_suffix
[]
=
"Appdata
\\
Ethash
\\
"
;
strbuf
[
0
]
=
'\0'
;
if
(
!
SUCCEEDED
(
SHGetFolderPathW
(
NULL
,
CSIDL_PROFILE
,
NULL
,
0
,
(
WCHAR
*
)
strbuf
)))
{
return
false
;
}
if
(
!
ethash_strncat
(
strbuf
,
buffsize
,
"
\\
"
,
1
))
{
return
false
;
}
close:
return
ethash_strncat
(
strbuf
,
buffsize
,
dir_suffix
,
sizeof
(
dir_suffix
));
fclose
(
f
);
free_memo:
free
(
memofile
);
end:
return
ret
;
}
}
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/mmap.h
0 → 100644
浏览文件 @
50659f4b
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file mmap.h
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#pragma once
#if defined(__MINGW32__) || defined(_WIN32)
#include <sys/types.h>
#define PROT_READ 0x1
#define PROT_WRITE 0x2
/* This flag is only available in WinXP+ */
#ifdef FILE_MAP_EXECUTE
#define PROT_EXEC 0x4
#else
#define PROT_EXEC 0x0
#define FILE_MAP_EXECUTE 0
#endif
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *) -1)
void
*
mmap
(
void
*
start
,
size_t
length
,
int
prot
,
int
flags
,
int
fd
,
off_t
offset
);
void
munmap
(
void
*
addr
,
size_t
length
);
#else // posix, yay! ^_^
#include <sys/mman.h>
#endif
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/mmap_win32.c
0 → 100644
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3.c
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3.h
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h
浏览文件 @
50659f4b
...
@@ -8,11 +8,10 @@
...
@@ -8,11 +8,10 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
struct
ethash_blockhash
;
struct
ethash_h256
;
typedef
struct
ethash_blockhash
ethash_blockhash_t
;
void
SHA3_256
(
ethash_blockhash_t
*
const
ret
,
const
uint8_t
*
data
,
size_t
size
);
void
SHA3_256
(
struct
ethash_h256
const
*
ret
,
uint8_t
const
*
data
,
size_t
size
);
void
SHA3_512
(
uint8_t
*
const
ret
,
const
uint8_t
*
data
,
size_t
size
);
void
SHA3_512
(
uint8_t
*
const
ret
,
uint8_t
const
*
data
,
size_t
size
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.c
→
Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util
_win32
.c
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/CMakeLists.txt
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go
已删除
100644 → 0
浏览文件 @
2e9ed6f7
此差异已折叠。
点击以展开。
Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
浏览文件 @
50659f4b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录