Browse Source

Fix cmake and linking

pool
Sammy Libre 8 years ago
parent
commit
61fe2a87f8
  1. 45
      README.md
  2. 28
      cnutil/CMakeLists.txt
  3. 13
      cnutil/cnutil.c
  4. 5
      cnutil/cnutil.go
  5. 12
      cnutil/cnutilxx/main.h
  6. 4
      cnutil/src/cnutil.cpp
  7. 10
      cnutil/src/cnutil.h
  8. 7
      hashing/CMakeLists.txt
  9. 2
      hashing/hashing.go

45
README.md

@ -8,55 +8,52 @@ High performance CryptoNote mining stratum written in Golang. @@ -8,55 +8,52 @@ High performance CryptoNote mining stratum written in Golang.
* AES-NI enabled share validation code with fallback to slow implementation
* Integrated NewRelic performance monitoring plugin
### Installation
## Installation
Dependencies:
* go-1.6
* Everything required to build monero
* Monero **v0.10.0**
* Monero >= **v0.10.0**
#### Mac OS X
### Linux
Install required packages:
Use Ubuntu 16.04 LTS.
brew update && brew install go
export GOPATH=~/go
go get github.com/yvasiyarov/gorelic
Compile Monero source (with libraries option):
Download and compile [Monero](https://github.com/monero-project/monero) **v0.10.0**.
cmake -DBUILD_SHARED_LIBS=1 .
make
Now clone stratum repo and compile it:
Install Golang and packages:
git clone https://github.com/sammy007/go-cryptonote-pool.git
cmake .
make
sudo apt-get install golang
export GOPATH=~/go
go get github.com/yvasiyarov/gorelic
Notice that for share validation stratum requires monero source tree where .a libs already compiled. By default stratum will use <code>../monero</code> directory. You can override this behavior by passing <code>MONERO_DIR</code> env variable:
Build CGO extensions:
MONERO_DIR=/path/to/monero cmake .
MONERO_DIR=/opt/src/monero cmake .
make
Build stratum:
go build -o pool main.go
#### Linux
### Mac OS X
I would recommend you to use Ubuntu 16.04 LTS.
Install Golang and packages packages:
Install required packages:
sudo apt-get install golang
brew update && brew install go
export GOPATH=~/go
go get github.com/yvasiyarov/gorelic
In order to successfully link with monero libs, recompile monero with:
Compile Monero source:
cmake .
CXXFLAGS="-fPIC" CFLAGS="-fPIC" make
make
Build CGO extensions:
Now clone stratum repo and compile it:
MONERO_DIR=/opt/src/monero cmake .
make
@ -65,11 +62,11 @@ Build stratum: @@ -65,11 +62,11 @@ Build stratum:
go build -o pool main.go
#### Running Stratum
### Running Stratum
./pool config.json
### Configuration
## Configuration
Configuration is self-describing, just copy *config.example.json* to *config.json* and run stratum with path to config file as 1st argument.

28
cnutil/CMakeLists.txt

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
set(CXXLIB "cnutilxx")
set(CXXLIB "cnutil")
find_package(Boost COMPONENTS thread system program_options date_time filesystem REQUIRED)
@ -9,14 +9,21 @@ include_directories(${Boost_INCLUDE_DIRS}) @@ -9,14 +9,21 @@ include_directories(${Boost_INCLUDE_DIRS})
include_directories("${MONERO_DIR}/contrib/epee/include")
include_directories("${MONERO_DIR}/src")
link_directories(
${MONERO_DIR}/src/cryptonote_core
${MONERO_DIR}/src/crypto
${MONERO_DIR}/src/common
${MONERO_DIR}/src/ringct
)
# Build library
add_library(${CXXLIB} SHARED cnutilxx/main.cpp)
add_library(${CXXLIB} SHARED src/cnutil.cpp)
target_link_libraries(${CXXLIB}
${MONERO_DIR}/src/cryptonote_core/libcryptonote_core.a
${MONERO_DIR}/src/crypto/libcrypto.a
${MONERO_DIR}/src/common/libcommon.a
${MONERO_DIR}/src/ringct/libringct.a
cryptonote_core
crypto
common
ringct
)
target_link_libraries(${CXXLIB}
@ -26,12 +33,3 @@ target_link_libraries(${CXXLIB} @@ -26,12 +33,3 @@ target_link_libraries(${CXXLIB}
${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
)
set(LIB "cnutil")
# Flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE")
# Build library
add_library(${LIB} SHARED cnutil.c)
target_link_libraries(${LIB} ${CXXLIB})

13
cnutil/cnutil.c

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
#include <stdint.h>
#include "stdbool.h"
#include <stdio.h>
#include <stdlib.h>
#include "cnutilxx/main.h"
uint32_t convert_blob(const char *blob, size_t len, char *out) {
return cn_convert_blob(blob, len, out);
}
bool validate_address(const char *addr, size_t len) {
return cn_validate_address(addr, len);
}

5
cnutil/cnutil.go

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
package cnutil
// #cgo CFLAGS: -std=c11 -D_GNU_SOURCE
// #cgo LDFLAGS: -L${SRCDIR} -lcnutil -lcnutilxx -lstdc++
// #include "cnutil.h"
// #cgo LDFLAGS: -L${SRCDIR} -lcnutil -Wl,-rpath ${SRCDIR} -lstdc++
// #include <stdlib.h>
// #include "src/cnutil.h"
import "C"
import "unsafe"

12
cnutil/cnutilxx/main.h

@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
uint32_t cn_convert_blob(const char *blob, uint32_t len, char *out);
bool cn_validate_address(const char *addr, uint32_t len);
#ifdef __cplusplus
}
#endif

4
cnutil/cnutilxx/main.cpp → cnutil/src/cnutil.cpp

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
using namespace cryptonote;
extern "C" uint32_t cn_convert_blob(const char *blob, size_t len, char *out) {
extern "C" uint32_t convert_blob(const char *blob, size_t len, char *out) {
std::string input = std::string(blob, len);
std::string output = "";
@ -19,7 +19,7 @@ extern "C" uint32_t cn_convert_blob(const char *blob, size_t len, char *out) { @@ -19,7 +19,7 @@ extern "C" uint32_t cn_convert_blob(const char *blob, size_t len, char *out) {
return output.length();
}
extern "C" bool cn_validate_address(const char *addr, size_t len) {
extern "C" bool validate_address(const char *addr, size_t len) {
std::string input = std::string(addr, len);
std::string output = "";
uint64_t prefix;

10
cnutil/cnutil.h → cnutil/src/cnutil.h

@ -1,7 +1,13 @@ @@ -1,7 +1,13 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32_t convert_blob(const char *blob, uint32_t len, char *out);
bool validate_address(const char *addr, uint32_t len);
#ifdef __cplusplus
}
#endif

7
hashing/CMakeLists.txt

@ -5,7 +5,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE") @@ -5,7 +5,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE")
include_directories("${MONERO_DIR}/contrib/epee/include")
include_directories("${MONERO_DIR}/src")
link_directories(${MONERO_DIR}/src/crypto)
add_library(${LIB} SHARED src/hashing.c)
target_link_libraries(${LIB}
${MONERO_DIR}/src/crypto/libcrypto.a
)
target_link_libraries(${LIB} crypto)

2
hashing/hashing.go

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
package hashing
// #cgo CFLAGS: -std=c11 -D_GNU_SOURCE
// #cgo LDFLAGS: -L${SRCDIR} -lhashing -lstdc++
// #cgo LDFLAGS: -L${SRCDIR} -lhashing -Wl,-rpath ${SRCDIR} -lstdc++
// #include <stdlib.h>
// #include <stdint.h>
// #include "src/hashing.h"

Loading…
Cancel
Save