Skip to content

Commit

Permalink
Devfund is on by default + some cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrlvi committed Dec 31, 2021
1 parent c59b90e commit 60e8078
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ There's a guide here on how to run a full node and how to generate addresses: ht

Help:
```
kaspa-miner 0.2.1
kaspa-miner 0.2.1-GPU-0.1
A Kaspa high performance CPU miner
USAGE:
Expand All @@ -55,16 +55,24 @@ FLAGS:
-h, --help Prints help information
--mine-when-not-synced Mine even when kaspad says it is not synced, only useful when passing `--allow-submit-
block-when-not-synced` to kaspad [default: false]
--no-gpu Disable GPU miner [default: false]
--testnet Use testnet instead of mainnet [default: false]
-V, --version Prints version information
--workload-absolute The values given by workload are not ratio, but absolute number of nonces [default:
false]
OPTIONS:
--devfund <devfund-address> Mine a percentage of the blocks to the Kaspa devfund [default: Off]
--cuda-device <cuda-device>... Which CUDA GPUs to use [default: all]
--devfund <devfund-address> Mine a percentage of the blocks to the Kaspa devfund [default:
kaspa:pzhh76qc82wzduvsrd9xh4zde9qhp0xc8rl7qu2mvl2e42uvdqt75zrcgpm00]
--devfund-percent <devfund-percent> The percentage of blocks to send to the devfund [default: 1]
-s, --kaspad-address <kaspad-address> The IP of the kaspad instance [default: 127.0.0.1]
-a, --mining-address <mining-address> The Kaspa address for the miner reward
-t, --threads <num-threads> Amount of miner threads to launch [default: number of logical cpus]
--opencl-device <opencl-device>... Which OpenCL GPUs to use (only GPUs currently. experimental) [default:
none]
-p, --port <port> Kaspad port [default: Mainnet = 16111, Testnet = 16211]
--workload <workload>... Ratio of nonces to GPU possible parrallel run [defualt: 16]
```

To start mining you just need to run the following:
Expand All @@ -74,7 +82,7 @@ To start mining you just need to run the following:
This will run the miner on all the available CPU cores.

# Devfund
**NOTE: This feature is off by default** <br>

The devfund is a fund managed by the Kaspa community in order to fund Kaspa development <br>
A miner that wants to mine a percentage into the dev-fund can pass the following flags: <br>
`kaspa-miner --mining-address= XXX --devfund=kaspa:precqv0krj3r6uyyfa36ga7s0u9jct0v4wg8ctsfde2gkrsgwgw8jgxfzfc98` <br>
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub struct Opt {
)]
pub kaspad_address: String,

#[structopt(long = "devfund", help = "Mine a percentage of the blocks to the Kaspa devfund [default: Off]")]
pub devfund_address: Option<String>,
#[structopt(long = "devfund", help = "Mine a percentage of the blocks to the Kaspa devfund", default_value = "kaspa:pzhh76qc82wzduvsrd9xh4zde9qhp0xc8rl7qu2mvl2e42uvdqt75zrcgpm00")]
pub devfund_address: String,

#[structopt(long = "devfund-percent", help = "The percentage of blocks to send to the devfund", default_value = "1", parse(try_from_str = parse_devfund_percent))]
pub devfund_percent: u16,
Expand Down
7 changes: 3 additions & 4 deletions src/gpu/cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl<'kernel> Kernel<'kernel> {
}

pub struct CudaGPUWork<'gpu> {
device_id: u32,
_context: Context,
_module: Arc<Module>,

Expand All @@ -78,10 +79,7 @@ pub struct CudaGPUWork<'gpu> {
impl<'gpu> GPUWork for CudaGPUWork<'gpu> {
fn id(&self) -> String {
let device = CurrentContext::get_device().unwrap();
format!("#{} ({})",
device.get_attribute(DeviceAttribute::PciDeviceId).unwrap(),
device.name().unwrap()
)
format!("#{} ({})", self.device_id, device.name().unwrap())

}

Expand Down Expand Up @@ -257,6 +255,7 @@ impl<'gpu> CudaGPUWork<'gpu> {
})?;
info!("GPU #{} initialized", device_id);
Ok(Self {
device_id,
_context,
_module: Arc::clone(&_module),
workload: chosen_workload,
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ async fn main() -> Result<(), Error> {
let mut client =
KaspadHandler::connect(opt.kaspad_address.clone(), opt.mining_address.clone(), opt.mine_when_not_synced)
.await?;
if let Some(devfund_address) = &opt.devfund_address {
client.add_devfund(devfund_address.clone(), opt.devfund_percent);
if opt.devfund_percent > 0 {
client.add_devfund( opt.devfund_address.clone(), opt.devfund_percent);
info!(
"devfund enabled, mining {}.{}% of the time to devfund address: {} ",
opt.devfund_percent / 100,
opt.devfund_percent % 100,
devfund_address
opt.devfund_address
);
}
client.client_send(NotifyBlockAddedRequestMessage {}).await?;
Expand Down

0 comments on commit 60e8078

Please sign in to comment.