nanopool / nanominer

Nanominer is a versatile tool for mining cryptocurrencies on GPUs and CPUs.
https://nanominer.org
640 stars 348 forks source link

3.8.0 multi-algorithm mining in API #386

Closed RainbowMiner closed 1 year ago

RainbowMiner commented 1 year ago

Hi,

where can I get the hashrates of all second, third, fourth algorithm, when mining 2/3/4 algos with the Nanominer API?

UselessGuru commented 1 year ago

~How to launch dual mining via command line (and not per config file)?~

https://github.com/nanopool/nanominer#launching-from-command-line

UselessGuru commented 1 year ago

This is how I get hash rates for dual algo:

    [Object]GetMinerData () { 
        $Timeout = 5 #seconds
        $Data = [PSCustomObject]@{ }
        $PowerUsage = [Double]0

        $Request = "http://127.0.0.1:$($this.Port)/stats"

        Try { 
            $Data = Invoke-RestMethod -Uri $Request -TimeoutSec $Timeout
        }
        Catch { 
            Return $null
        }

        If (-not $Data) { Return $null }

        $HashRate = [PSCustomObject]@{ }
        $HashRate_Name = ""
        $HashRate_Value = [Double]0

        $Shares = [PSCustomObject]@{ }
        $Shares_Accepted = [Int64]0
        $Shares_Rejected = [Int64]0

        $Algorithms = @($Data.Algorithms | ForEach-Object { ($_ | Get-Member -MemberType NoteProperty).Name } | Select-Object -Unique)

        ForEach ($Algorithm in $Algorithms) { 
            $HashRate_Name = Get-Algorithm $this.Algorithms[$Algorithms.IndexOf($Algorithm)]
            $HashRate_Value = [Double]($Data.Algorithms.$Algorithm.Total.Hashrate | Measure-Object -Sum).Sum
            $HashRate | Add-Member @{ $HashRate_Name = [Double]$HashRate_Value }

            $Shares_Accepted = [Int64]($Data.Algorithms.$Algorithm.Total.Accepted | Measure-Object -Sum).Sum
            $Shares_Rejected = [Int64]($Data.Algorithms.$Algorithm.Total.Denied | Measure-Object -Sum).Sum
            $Shares_Invalid = [Int64]0
            $Shares | Add-Member @{ $HashRate_Name = @($Shares_Accepted, $Shares_Rejected, $Shares_Invalid, ($Shares_Accepted + $Shares_Rejected + $Shares_Invalid)) }
        }

        If ($this.ReadPowerUsage) { 
            $PowerUsage = $this.GetPowerUsage()
        }

        If ($HashRate.PSObject.Properties.Value -gt 0) { 
            Return [PSCustomObject]@{ 
                Date       = (Get-Date).ToUniversalTime()
                HashRate   = $HashRate
                PowerUsage = $PowerUsage
                Shares     = $Shares
            }
        }
        Return $null
    }

I have not tried 3/4 algo mining.

RainbowMiner commented 1 year ago

Super! Thank you!