Browse Source

Add new build system

pool
Sammy Libre 7 years ago
parent
commit
36364a5e1e
  1. 4
      .gitignore
  2. 9
      CMakeLists.txt
  3. 14
      README.md
  4. 32
      build/env.sh
  5. 4
      main.go
  6. 0
      pool/pool.go
  7. 2
      rpc/rpc.go
  8. 4
      stratum/api.go
  9. 2
      stratum/blocks.go
  10. 2
      stratum/handlers.go
  11. 6
      stratum/miner.go
  12. 0
      stratum/mmap.go
  13. 0
      stratum/proto.go
  14. 6
      stratum/stratum.go
  15. 2
      util/util.go
  16. 0
      util/util_test.go

4
.gitignore vendored

@ -17,4 +17,6 @@ Makefile @@ -17,4 +17,6 @@ Makefile
config.json
testnet.json
mainnet.json
pool
/build/_workspace/
/build/bin/

9
CMakeLists.txt

@ -1,5 +1,5 @@ @@ -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)
@ -11,3 +11,10 @@ endif() @@ -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
README.md

@ -38,10 +38,6 @@ Compile Monero source (with shared libraries option): @@ -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:
@ -52,7 +48,6 @@ Build stratum: @@ -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 .`.
@ -69,10 +64,6 @@ Compile Monero source: @@ -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:
@ -83,16 +74,15 @@ Build stratum: @@ -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

32
build/env.sh

@ -0,0 +1,32 @@ @@ -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
main.go

@ -10,8 +10,8 @@ import ( @@ -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"

0
go-pool/pool/pool.go → pool/pool.go

2
go-pool/rpc/rpc.go → rpc/rpc.go

@ -11,7 +11,7 @@ import ( @@ -11,7 +11,7 @@ import (
"sync/atomic"
"time"
"../pool"
"github.com/sammy007/monero-stratum/pool"
)
type RPCClient struct {

4
go-pool/stratum/api.go → stratum/api.go

@ -6,8 +6,8 @@ import ( @@ -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) {

2
go-pool/stratum/blocks.go → stratum/blocks.go

@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
"encoding/hex"
"log"
"../../cnutil"
"github.com/sammy007/monero-stratum/cnutil"
)
type BlockTemplate struct {

2
go-pool/stratum/handlers.go → stratum/handlers.go

@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
"strings"
"sync/atomic"
"../util"
"github.com/sammy007/monero-stratum/util"
)
var noncePattern *regexp.Regexp

6
go-pool/stratum/miner.go → stratum/miner.go

@ -10,9 +10,9 @@ import ( @@ -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 {

0
go-pool/stratum/mmap.go → stratum/mmap.go

0
go-pool/stratum/proto.go → stratum/proto.go

6
go-pool/stratum/stratum.go → stratum/stratum.go

@ -12,9 +12,9 @@ import ( @@ -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 {

2
go-pool/util/util.go → util/util.go

@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
"time"
"unicode/utf8"
"../../cnutil"
"github.com/sammy007/monero-stratum/cnutil"
)
var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")

0
go-pool/util/util_test.go → util/util_test.go

Loading…
Cancel
Save