Json value converting error of NetworkHashps #12439

issue jeong760 opened this issue on February 15, 2018
  1. jeong760 commented at 3:08 AM on February 15, 2018: none

    I have a problem to get a NetworkHashps using JSON request after upgrade of 15.01 bitcoin core. so cannot make a mining pool for bitcoin using CoiniumServ..

    The issues are Nancy.TinyIoc.TinyIoCResolutionException: Unable to resolve type: CoiniumServ.Pools.INetworkInfo ---> Nancy.TinyIoc.TinyIoCResolutionException: Unable to resolve type: CoiniumServ.Pools.NetworkInfo ---> System.Exception: There was a problem deserializing the response from the coin wallet. ---> Newtonsoft.Json.JsonSerializationException: Error converting value 1.98121075128195E+19 to type 'System.UInt64'. Path 'result.networkhashps', line 1, position 158. ---> System.OverflowException: Arithmetic operation resulted in an overflow.

    So I want to know where should I changed to prevent this error.

    Regards, John Ahn

  2. jeong760 commented at 3:10 AM on February 15, 2018: none

    Dears,

    This is a CoiniumServ code for handling Json response.

    /src/pool/DaemonBase.cs private DaemonResponse GetRpcResponse(HttpWebRequest httpWebRequest) { string json = GetJsonResponse(httpWebRequest);

        _logger.Verbose("rx: {0}", json.PrettifyJson());
    
        try
        {
            return JsonConvert.DeserializeObject<DaemonResponse<T>>(json);
        }
        catch (JsonException jsonEx)
        {
            httpWebRequest = null;
            throw new Exception("There was a problem deserializing the response from the coin wallet.", jsonEx);
        }

    src/Daemon/DaemonResponse.cs [JsonProperty] private UInt64 NetworkHashps { get; set; }

    [JsonIgnore]
    public UInt64 NetworkHashPerSec { get; set; }
    
    [OnDeserialized]
    internal void OnDeserializedMethod(StreamingContext context)
    {
        NetworkHashPerSec = 0;
    
        if (NetMHashps > 0)
            NetworkHashPerSec = (UInt64)(NetMHashps*1000*1000);
        else if (NetworkGhps > 0)
            NetworkHashPerSec = (UInt64)(NetworkGhps * 1000 * 1000 * 1000);
        else if (NetworkMhps > 0)
            NetworkHashPerSec = (UInt64)(NetworkMhps * 1000 * 1000);
        else if (NetworkHashps > 0)
            NetworkHashPerSec = NetworkHashps;
  3. sipa commented at 5:30 AM on February 15, 2018: member

    You can't represent this value as a uint64 anymore, you'll need to use a double or a larger integer type.

    This has nothing to do with a change in Bitcoin Core, but with the fact that the network's hashrate is now too large for your software to deal with.

  4. sipa closed this on Feb 15, 2018

  5. jeong760 commented at 7:34 AM on February 15, 2018: none

    @sipa, thanks your advise. I will made change and update here

  6. DrahtBot locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 06:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me