mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00

* [NOD-570] Separate genesis variables for different netwroks * [NOD-570] Make Testnet genesis * [NOD-570] Make simnet and regtest genesis * [NOD-570] Remake devnet genesis * [NOD-570] Rename regNet -> regTest testnet->testNet * [NOD-570] Change network names to one word instead of camel case * [NOD-570] Change network names to one word instead of camel case * [NOD-570] Fix test names * [NOD-570] Fix TestGHOSTDAG Co-authored-by: Dan Aharoni <dereeno@protonmail.com>
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package rpc
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/config"
|
|
"github.com/kaspanet/kaspad/rpcmodel"
|
|
)
|
|
|
|
// handleGetMiningInfo implements the getMiningInfo command. We only return the
|
|
// fields that are not related to wallet functionality.
|
|
func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
if config.ActiveConfig().SubnetworkID != nil {
|
|
return nil, &rpcmodel.RPCError{
|
|
Code: rpcmodel.ErrRPCInvalidRequest.Code,
|
|
Message: "`getMiningInfo` is not supported on partial nodes.",
|
|
}
|
|
}
|
|
|
|
selectedTipHash := s.cfg.DAG.SelectedTipHash()
|
|
selectedBlock, err := s.cfg.DAG.BlockByHash(selectedTipHash)
|
|
if err != nil {
|
|
return nil, &rpcmodel.RPCError{
|
|
Code: rpcmodel.ErrRPCInternal.Code,
|
|
Message: "could not find block for selected tip",
|
|
}
|
|
}
|
|
|
|
result := rpcmodel.GetMiningInfoResult{
|
|
Blocks: int64(s.cfg.DAG.BlockCount()),
|
|
CurrentBlockSize: uint64(selectedBlock.MsgBlock().SerializeSize()),
|
|
CurrentBlockTx: uint64(len(selectedBlock.MsgBlock().Transactions)),
|
|
Difficulty: getDifficultyRatio(s.cfg.DAG.CurrentBits(), s.cfg.DAGParams),
|
|
Generate: s.cfg.CPUMiner.IsMining(),
|
|
GenProcLimit: s.cfg.CPUMiner.NumWorkers(),
|
|
HashesPerSec: int64(s.cfg.CPUMiner.HashesPerSecond()),
|
|
PooledTx: uint64(s.cfg.TxMemPool.Count()),
|
|
Testnet: config.ActiveConfig().Testnet,
|
|
Devnet: config.ActiveConfig().Devnet,
|
|
}
|
|
return &result, nil
|
|
}
|