@@ -2355,11 +2355,11 @@ func handleGetMiningInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{
2355
2355
if err != nil {
2356
2356
return nil , err
2357
2357
}
2358
- networkHashesPerSec , ok := networkHashesPerSecIface .(int64 )
2358
+ networkHashesPerSec , ok := networkHashesPerSecIface .(float64 )
2359
2359
if ! ok {
2360
2360
return nil , & btcjson.RPCError {
2361
2361
Code : btcjson .ErrRPCInternal .Code ,
2362
- Message : "networkHashesPerSec is not an int64 " ,
2362
+ Message : "networkHashesPerSec is not a float64 " ,
2363
2363
}
2364
2364
}
2365
2365
@@ -2373,7 +2373,7 @@ func handleGetMiningInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{
2373
2373
Generate : s .cfg .CPUMiner .IsMining (),
2374
2374
GenProcLimit : s .cfg .CPUMiner .NumWorkers (),
2375
2375
HashesPerSec : s .cfg .CPUMiner .HashesPerSecond (),
2376
- NetworkHashPS : float64 ( networkHashesPerSec ) ,
2376
+ NetworkHashPS : networkHashesPerSec ,
2377
2377
PooledTx : uint64 (s .cfg .TxMemPool .Count ()),
2378
2378
TestNet : cfg .TestNet3 ,
2379
2379
}
@@ -2393,8 +2393,8 @@ func handleGetNetTotals(s *rpcServer, cmd interface{}, closeChan <-chan struct{}
2393
2393
2394
2394
// handleGetNetworkHashPS implements the getnetworkhashps command.
2395
2395
func handleGetNetworkHashPS (s * rpcServer , cmd interface {}, closeChan <- chan struct {}) (interface {}, error ) {
2396
- // Note: All valid error return paths should return an int64 .
2397
- // Literal zeros are inferred as int, and won't coerce to int64
2396
+ // Note: All valid error return paths should return a float64 .
2397
+ // Literal zeros are inferred as int, and won't coerce to float64
2398
2398
// because the return value is an interface{}.
2399
2399
2400
2400
c := cmd .(* btcjson.GetNetworkHashPSCmd )
@@ -2409,7 +2409,7 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru
2409
2409
endHeight = int32 (* c .Height )
2410
2410
}
2411
2411
if endHeight > best .Height || endHeight == 0 {
2412
- return int64 (0 ), nil
2412
+ return float64 (0 ), nil
2413
2413
}
2414
2414
if endHeight < 0 {
2415
2415
endHeight = best .Height
@@ -2476,13 +2476,13 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru
2476
2476
// Calculate the difference in seconds between the min and max block
2477
2477
// timestamps and avoid division by zero in the case where there is no
2478
2478
// time difference.
2479
- timeDiff := int64 ( maxTimestamp .Sub (minTimestamp ) / time . Second )
2479
+ timeDiff := maxTimestamp .Sub (minTimestamp ). Seconds ( )
2480
2480
if timeDiff == 0 {
2481
- return int64 ( 0 ) , nil
2481
+ return timeDiff , nil
2482
2482
}
2483
2483
2484
- hashesPerSec := new (big.Int ). Div ( totalWork , big .NewInt (timeDiff ))
2485
- return hashesPerSec . Int64 () , nil
2484
+ hashesPerSec , _ := new (big.Float ). Quo ( new (big. Float ). SetInt ( totalWork ), new ( big.Float ). SetFloat64 (timeDiff )). Float64 ( )
2485
+ return hashesPerSec , nil
2486
2486
}
2487
2487
2488
2488
// handleGetNodeAddresses implements the getnodeaddresses command.
0 commit comments