diff --git a/.gitignore b/.gitignore index f084d36..1c2a5aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ __pycache__/ venv/ .venv/ -config.py \ No newline at end of file +config.py +*.o +miner +launcher diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6046046 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +CC := gcc +CFLAGS := -O3 -Wall -Wextra -std=c11 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L +LDFLAGS := -pthread -lcrypto -lm + +COMMON_OBJS := config.o utils.o json.o rpc.o types.o block_builder.o miner.o mining_loop.o + +.PHONY: all clean + +all: miner launcher + +miner: main.o $(COMMON_OBJS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +launcher: launcher.o $(COMMON_OBJS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -f *.o miner launcher diff --git a/miner.conf.example b/miner.conf.example new file mode 100644 index 0000000..64bda2e --- /dev/null +++ b/miner.conf.example @@ -0,0 +1,23 @@ +# RPC +RPC_USER=regtest +RPC_PASSWORD=regtest +RPC_HOST=127.0.0.1 +RPC_PORT=18443 + +# Wallet +WALLET_ADDRESS=bcrt1qn9ewln06n3xmc64278nj8m4nyde7ddeuvsvhw6 + +# Mining +DIFFICULTY_FACTOR=0.01 +NONCE_MODE=incremental # incremental | random | mixed +TIMESTAMP_UPDATE_INTERVAL=30 +BATCH=10000 +COINBASE_MESSAGE=/c-miner/ +EXTRANONCE1=1234567890abcdef +EXTRANONCE2=12341234 + +# Workers +NUM_PROCESSORS=0 # <=0 uses CPU count + +# Watchdog +CHECK_INTERVAL=20