Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RPC][Mining] Extract last Hashspeed calculation #883

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

CaveSpectre11
Copy link
Collaborator

@CaveSpectre11 CaveSpectre11 commented Dec 11, 2020

Problem

Users want to be able to see their current hashing speed

Solution

Extract the last calculated hashspeed and provide it in getmininginfo. To note, this only pulls the last calculation that was done, and is not a real-time pull. It will be the average from the start of mining to the last calculation, from the time the first generatecontinuous true was run. In other words, this will take into account any 'breaks' taken in mining. e.g. if you have a script that turns off mining for a certain time; the hash speed calculations are still being run; and the break will be calculated into your overall hash rate.

Logic was added to setminingalgo to reset the statistical counters. So after setminingalgo is issued, the statistics will restart on the next generatecontinuous. This can be used to reset your counters even if you're not changing algorithms by setting your mining algo to the same algo:

$ ./veil-cli -regtest getmininginfo
{
[...]
  "hashspeed": 743034,
[...]
}
$ ./veil-cli -regtest setminingalgo sha256d
{
  "success": true,
  "message": "Mining algorithm changed from sha256d to sha256d"
}
$ ./veil-cli -regtest getmininginfo
{
[...]
  "hashspeed": 0,
}

Note that for simplicity sake, the calculation is "hashes per second", so that it can remain a numerical value and users can wrap the use however they wish if they want to convert it to kh/s or mh/s [or whatever they desire]

@CaveSpectre11 CaveSpectre11 added Component: RPC Related to the console commands themselves. Component: Miner Both PoW and PoS block creation labels Dec 11, 2020
@CaveSpectre11 CaveSpectre11 self-assigned this Dec 11, 2020
@CaveSpectre11
Copy link
Collaborator Author

This addresses issue #875

@codeofalltrades
Copy link
Collaborator

Looks goods

{
  "blocks": 1002401,
  "currentblockweight": 43832,
  "currentblocktx": 2,
  "algorithm": "sha256d",
  "difficulty": 18.71628533785223,
  "networkhashps": 23.47822805181118,
  "hashspeed": 351949,
  "pooledtx": 2,
  "chain": "main",
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
{
  "blocks": 1002409,
  "currentblockweight": 31364,
  "currentblocktx": 1,
  "algorithm": "randomx",
  "difficulty": 0.003405607281592146,
  "networkhashps": 23.28523685595233,
  "hashspeed": 43,
  "pooledtx": 1,
  "chain": "main",
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}```

Copy link
Collaborator

@codeofalltrades codeofalltrades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ea18c5a

@codeofalltrades codeofalltrades merged commit 1194909 into Veil-Project:master Dec 14, 2020
@CaveSpectre11 CaveSpectre11 added this to the v1.1.1 milestone Dec 17, 2020
@CaveSpectre11 CaveSpectre11 deleted the gethash branch December 31, 2020 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Miner Both PoW and PoS block creation Component: RPC Related to the console commands themselves.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants