Skip to content

Commit

Permalink
Add new build system
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy007 committed Sep 9, 2017
1 parent 0c71aab commit 36364a5
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ Makefile
config.json
testnet.json
mainnet.json
pool

/build/_workspace/
/build/bin/
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 2.8.11)
project (pool)
project(pool)

if (DEFINED ENV{MONERO_DIR})
get_filename_component(MONERO_DIR $ENV{MONERO_DIR} ABSOLUTE)
Expand All @@ -11,3 +11,10 @@ endif()

add_subdirectory(hashing)
add_subdirectory(cnutil)

add_custom_command(
OUTPUT build/bin
COMMAND build/env.sh go get -v ./...
)

add_custom_target(build ALL DEPENDS hashing cnutil ${CMAKE_CURRENT_BINARY_DIR}/build/bin)
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ Compile Monero source (with shared libraries option):
Install Golang and required packages:

sudo apt-get install golang
export GOPATH=~/go
go get github.com/goji/httpauth
go get github.com/yvasiyarov/gorelic
go get github.com/gorilla/mux

Clone stratum:

Expand All @@ -52,7 +48,6 @@ Build stratum:

MONERO_DIR=/path/to/monero cmake .
make
go build -o pool main.go

`MONERO_DIR=/path/to/monero` is optional, not needed if both `monero` and `monero-stratum` is in the same directory like `/opt/src/`. By default make will search for monero libraries in `../monero`. You can just run `cmake .`.

Expand All @@ -69,10 +64,6 @@ Compile Monero source:
Install Golang and required packages:

brew update && brew install go
export GOPATH=~/go
go get github.com/goji/httpauth
go get github.com/yvasiyarov/gorelic
go get github.com/gorilla/mux

Clone stratum:

Expand All @@ -83,16 +74,15 @@ Build stratum:

MONERO_DIR=/path/to/monero cmake .
make
go build -o pool main.go

### Running Stratum

./pool config.json
./build/bin/monero-stratum config.json

If you need to bind to privileged ports and don't want to run from `root`:

sudo apt-get install libcap2-bin
sudo setcap 'cap_net_bind_service=+ep' pool
sudo setcap 'cap_net_bind_service=+ep' /path/to/monero-stratum

## Configuration

Expand Down
32 changes: 32 additions & 0 deletions build/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

if [ ! -f "build/env.sh" ]; then
echo "$0 must be run from the root of the repository."
exit 2
fi

# Create fake Go workspace if it doesn't exist yet.
workspace="$PWD/build/_workspace"
root="$PWD"
ethdir="$workspace/src/github.com/sammy007"
if [ ! -L "$ethdir/monero-stratum" ]; then
mkdir -p "$ethdir"
cd "$ethdir"
ln -s ../../../../../. monero-stratum
cd "$root"
fi

# Set up the environment to use the workspace.
# Also add Godeps workspace so we build using canned dependencies.
GOPATH="$workspace"
GOBIN="$PWD/build/bin"
export GOPATH GOBIN

# Run the command inside the workspace.
cd "$ethdir/monero-stratum"
PWD="$ethdir/monero-stratum"

# Launch the arguments with the configured environment.
exec "$@"
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"runtime"
"time"

"./go-pool/pool"
"./go-pool/stratum"
"github.com/sammy007/monero-stratum/pool"
"github.com/sammy007/monero-stratum/stratum"

"github.com/goji/httpauth"
"github.com/gorilla/mux"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion go-pool/rpc/rpc.go → rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync/atomic"
"time"

"../pool"
"github.com/sammy007/monero-stratum/pool"
)

type RPCClient struct {
Expand Down
4 changes: 2 additions & 2 deletions go-pool/stratum/api.go → stratum/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync/atomic"
"time"

"../rpc"
"../util"
"github.com/sammy007/monero-stratum/rpc"
"github.com/sammy007/monero-stratum/util"
)

func (s *StratumServer) StatsIndex(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion go-pool/stratum/blocks.go → stratum/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/hex"
"log"

"../../cnutil"
"github.com/sammy007/monero-stratum/cnutil"
)

type BlockTemplate struct {
Expand Down
2 changes: 1 addition & 1 deletion go-pool/stratum/handlers.go → stratum/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"sync/atomic"

"../util"
"github.com/sammy007/monero-stratum/util"
)

var noncePattern *regexp.Regexp
Expand Down
6 changes: 3 additions & 3 deletions go-pool/stratum/miner.go → stratum/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"sync/atomic"
"time"

"../../cnutil"
"../../hashing"
"../util"
"github.com/sammy007/monero-stratum/cnutil"
"github.com/sammy007/monero-stratum/hashing"
"github.com/sammy007/monero-stratum/util"
)

type Job struct {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions go-pool/stratum/stratum.go → stratum/stratum.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"sync/atomic"
"time"

"../pool"
"../rpc"
"../util"
"github.com/sammy007/monero-stratum/pool"
"github.com/sammy007/monero-stratum/rpc"
"github.com/sammy007/monero-stratum/util"
)

type StratumServer struct {
Expand Down
2 changes: 1 addition & 1 deletion go-pool/util/util.go → util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
"unicode/utf8"

"../../cnutil"
"github.com/sammy007/monero-stratum/cnutil"
)

var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
Expand Down
File renamed without changes.

0 comments on commit 36364a5

Please sign in to comment.