From 5ac0f1247dfe6e04557fde4037e5d69f5aab0c69 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Sat, 28 Feb 2015 21:40:13 -0500 Subject: [PATCH] Fix return types for handleGetNetworkHashPS. --- rpcserver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 7378247d..1a9dd958 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1816,6 +1816,10 @@ func handleGetNetTotals(s *rpcServer, cmd interface{}, closeChan <-chan struct{} // handleGetNetworkHashPS implements the getnetworkhashps command. func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { + // Note: All valid error return paths should return an int64. + // Literal zeros are inferred as int, and won't coerce to int64 + // because the return value is an interface{}. + c := cmd.(*btcjson.GetNetworkHashPSCmd) _, newestHeight, err := s.server.db.NewestSha() @@ -1833,7 +1837,7 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru endHeight = int64(*c.Height) } if endHeight > newestHeight || endHeight == 0 { - return 0, nil + return int64(0), nil } if endHeight < 0 { endHeight = newestHeight @@ -1896,7 +1900,7 @@ func handleGetNetworkHashPS(s *rpcServer, cmd interface{}, closeChan <-chan stru // time difference. timeDiff := int64(maxTimestamp.Sub(minTimestamp) / time.Second) if timeDiff == 0 { - return 0, nil + return int64(0), nil } hashesPerSec := new(big.Int).Div(totalWork, big.NewInt(timeDiff))