Skip to content

Commit

Permalink
Default to mine-throttling
Browse files Browse the repository at this point in the history
Recursion will fix syncing problems related to reorganizations, so we
don't need to test that as often as we do now, when mine-throttling is
off by default. Therefore, it's sensible to default to mine throttling,
at least as long as we're on test net.

This closes #76.
  • Loading branch information
Sword-Smith committed Jan 4, 2024
1 parent dfde0e5 commit 246b813
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Neptune-core is the reference implementation for the [Neptune](https://neptune.c
- Generate a wallet file: `neptune-wallet-gen`
- Run neptune-core daemon: `neptune-core` with flags
- `--peers [ip_address:port]` to connect to a given peer, for instance `--peers 51.15.139.238:9798` or `--peers 139.162.193.206:9798` or both
- `--mine` to mine, and with `--throttled-mining` to avoid assigning too much CPU power to mining
- `--mine` to mine — if you want to generate testnet coins to test sending and receiving
- `--help` to get a list of available command-line arguments

## Dashboard
Expand Down
4 changes: 2 additions & 2 deletions scripts/linux/run-multiple-instances.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ set -e # Exit on first error.

export RUST_LOG=debug;

RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/0/ nice -n 18 -- cargo run -- --network regtest --peer-port 29790 --rpc-port 19790 --mine --throttled-mining 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I0: \1/g' &
RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/0/ nice -n 18 -- cargo run -- --network regtest --peer-port 29790 --rpc-port 19790 --mine 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I0: \1/g' &
pid[0]=$!
sleep 5s;
RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/1/ nice -n 18 -- cargo run -- --network regtest --peer-port 29791 --rpc-port 19791 --peers 127.0.0.1:29790 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I1: \1/g' &
pid[1]=$!
sleep 5s;
RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/2/ nice -n 18 -- cargo run -- --network regtest --peer-port 29792 --rpc-port 19792 --peers 127.0.0.1:29791 --mine --throttled-mining --max-number-of-blocks-before-syncing 1000 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I2: \1/g' &
RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/2/ nice -n 18 -- cargo run -- --network regtest --peer-port 29792 --rpc-port 19792 --peers 127.0.0.1:29791 --mine --max-number-of-blocks-before-syncing 1000 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I2: \1/g' &
pid[2]=$!

# Inspired by https://stackoverflow.com/a/52033580/2574407
Expand Down
2 changes: 1 addition & 1 deletion scripts/linux/run-single-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e # Exit on first error.

export RUST_LOG=debug;

RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/0/ nice -n 18 -- cargo run -- --network regtest --peer-port 29790 --rpc-port 19790 --mine --throttled-mining 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I0: \1/g' &
RUST_BACKTRACE=1 XDG_DATA_HOME=~/.local/share/neptune-integration-test/0/ nice -n 18 -- cargo run -- --network regtest --peer-port 29790 --rpc-port 19790 --mine 2>&1 | tee -a integration_test.log | sed 's/.*neptune_core:\+\(.*\)/I0: \1/g' &
pid[0]=$!
sleep 5s;

Expand Down
4 changes: 2 additions & 2 deletions src/config_models/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ pub struct Args {
#[clap(long)]
pub mine: bool,

/// If mining, restrict CPU time spent in mining thread. Ignored if mine flag not set.
/// If mining, use all available CPU power. Ignored if mine flag not set.
#[clap(long)]
pub throttled_mining: bool,
pub unrestricted_mining: bool,

/// Prune the mempool when it exceeds this size in RAM.
///
Expand Down
2 changes: 1 addition & 1 deletion src/mine_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async fn mine_block(

// Mining takes place here
while Hash::hash(&block_header) >= threshold {
if state.cli.throttled_mining {
if !state.cli.unrestricted_mining {
tokio::time::sleep(Duration::from_millis(100)).await;
}

Expand Down

0 comments on commit 246b813

Please sign in to comment.