bonesoul / CoiniumServ

Next-gen crypto currency mining pool software
Other
801 stars 494 forks source link

CoiniumServ needs to add a new command for coin wallet v0.16.0 instead of use a getinfo() #975

Closed jeong760 closed 6 years ago

jeong760 commented 6 years ago

@bonesoul,

After I've upgrade of bitcoin and globaltoken wallet core v0.16.0 the following problem occurred. So could you give me an idea where I put new command for support and get following info from the new wallet?

[Information] [NetworkInfo] [Bitcoin] symbol: BTC algorithm: sha256 version: null protocol: 0 wallet: 0 network difficulty: 3007383866429.73000000 block difficulty: 3007383866429.73 network hashrate: 23.10 EH/s network: mainnet peers: 0 blocks: 512021 errors: none

07:14:51 [Error] [NetworkInfo] [Bitcoin] Can not read getinfo(): getinfo This call was removed in version 0.16.0. Use the appropriate fields from:

bitcoin-cli has the option -getinfo to collect and format these in the old format.

jeong760 commented 6 years ago

@dmshel I've tested with my last commit on git of my repo. but there is no such kind of problem you mentioned above. here is proven screenshot.

So before you made a full test do not say or write that your code has a problem with mine because most case related to the setting.

Also, my last repo only has a PaymentProcessor problem due to Globaltoken does not get a IsMine result value from the validateaddress. so currently all payment processor has been disabled except this mining and block found are working well.

The CoiniumServ with BTC, LTC, and GLT...

capture_20180311-1

The webpage screenshot webpage_20180311

Regards, John Ahn

jeong760 commented 6 years ago

@dmshel You know that each pool uses a different Redis DB if not you will encounter a problem with your screenshot. I am assigning different Redis DB for all of three coins pool. and also MySql I've created and assigned a different database for them.

Please try to running LTC with different Redis DB.

dmshel commented 6 years ago

i am rebuild stock server. I see only one error redis server is ok coin demon only one litecoin How fix this error? default

jeong760 commented 6 years ago

@dmshel, I don't know. as I mentioned this above this is not related to my code change because I didn't have such problem with Redis (It seems MySql DB not Redis). Also, this seems not related to this post...

Have you try to use another Redis DB in your litecoin.json of CoiniumServ?

"storage": {
    "hybrid": {
        "enabled": true,
        "redis": {
            "host": "127.0.0.1",
            "port": 6379,
            "password": "",
            "databaseId": 0 <---- change this value to another number, you can able to use from 0 to 15.

Could you try to create a new MySql DB for Litecoin? based on your screenshot Migration manager trying to create a block table on litecoin database but it exists already. So Migration manager has skip to create a block table on litecoin database

Just I download a dogecoin and setup onto my 4th mining pool but hasn't such kind of issue at all. so please open a new issue if you still have an issue with detail descriptions such OS, configuration file setting etc...

The screenshot of CoiniumServ with BTC, DOGE, LTC, and GLT.

There is DOGEcoin related error because it does not fully sync yet. still downloading blocks...

capture_20180311-2

The screenshot of the webpage. webpage_20180311-1

Regards, John Ahn

dmshel commented 6 years ago

ok tnx! last error))) default Halted as daemon we are connected to does not own the pool address: 33x8QzcNZXoT................. i see u have 2 this error

jeong760 commented 6 years ago

@dmshel, GetInfo() error you need to add this code. and Payment processor halted issue you need to change back code related to paymentprocessor(refers to above post) and compile again for this moment.

Because I've added a code to DaemonClient.cs, IDaemonClient.cs, PaymentProcessor.cs to get a IsMine result from a Getnetworkinfo() of Globaltoken(GLT)** but it seems affect normal coin's works.

please removed or make a comment on them, then payment processor error will disappear. each number represents a code that I inserted so chang back and compile again, then your issue solved.

Change back code for GetAddressInfo() ( Removed a PaymentProcessorr error) related. 032685431da4440d2af31e5340eafc107edaeda6

Added a code to support a Getinfo() or Getnetworkinfo() by coin's wallet version. 0bbeef2f4463e74a088d562eb6aeb7b7347f9cdb

Or use this compiles version, which applied a Getinfo() or Getnetworkinfo() command support by coin version. Release(remvoed_payment_error).zip

Regards, John Ahn

jeong760 commented 6 years ago

@Bonesoul, in order to confused please consideration to update a my last PR into your deveolop repo and releases a CoiniumServ-2.6.3-beta.zip

dmshel commented 6 years ago

I try use Release(remvoed_payment_error).zip after start 1 default What i doung wrong?

jeong760 commented 6 years ago

@dmshel,

This is last time I will support this. Please do your self troubleshoot. also this seems not related my recent code change on CoiniumServ. Which not merged so if you think have an error please re-clone a CoiniumServ Repo of Bonesole.

Regards, John Ahn -----Original Message----- From: "dmshel"notifications@github.com To: "bonesoul/CoiniumServ"CoiniumServ@noreply.github.com; Cc: "John Ahn"jeong760@naver.com; "Mention"mention@noreply.github.com; Sent: 2018-03-12 (월) 10:57:29 Subject: Re: [bonesoul/CoiniumServ] CoiniumServ needs to add a new command for coin wallet v0.16.0 instead of use a getinfo() (#975)

I try use Release(remvoed_payment_error).zip after start

What i doung wrong? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

dmshel commented 6 years ago

tnx for help

jeong760 commented 6 years ago

@dmshel, Please refer to how to install Stackexchange Redis using Package Manager of Visual Studio. if not installation a Visual Studio community and try to make a compile it on Windows and copy compile onto Linux works well I think.

https://stackexchange.github.io/StackExchange.Redis/

Or download and running a monobuild.cmd or monobuild.bash script file on sources.

https://github.com/StackExchange/StackExchange.Redis/archive/1.2.6.tar.gz

dmshel commented 6 years ago

@jeong760 Tnx! Solved!

jeong760 commented 6 years ago

@bonesoul and @globaltoken,

Globaltoken has been merged a Bitcoin V0.16.0, which split into a IsValid resuit from Validateaddress() and IsMine result from GetAddressInfo().

As you see the ValidateAddress() of Bitcoin v0.16.0, which still uses it. but both of IsValid and IsMine able to get one command.

So I need to your help to split or trying to get necessary information only from those two command.

Validateaddress from Bitcoin 14:08:26 validateaddress xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 14:08:26 { "isvalid": true, "address": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "scriptPubKey": "00000000000000000000000000000000000000000000000000", "ismine": true, "iswatchonly": false, "isscript": false, "iswitness": false, "pubkey": "000000000000000000000000000000000000000000000000000000000000000000", "iscompressed": true, "account": "", "timestamp": 1 }

However Globaltoken and later Bitcoin V0.17.0 are need to use a two different command to get a IsVaild and IsMine result from them.

Validateaddress from Globaltoken 13:53:37 validateaddress xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 13:53:37 { "isvalid": true, "address": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "scriptPubKey": "00000000000000000000000000000000000000000000000000", "isscript": false, "iswitness": false }

GetAddressInfo from Globaltoken 13:53:49 getaddressinfo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 13:53:50 { "address": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"scriptPubKey": "00000000000000000000000000000000000000000000000000", "ismine": true, "iswatchonly": false, "isscript": false, "iswitness": false,
"pubkey": "000000000000000000000000000000000000000000000000000000000000000000", "iscompressed": true, "account": "Private", "timestamp": 1501801831, "hdkeypath": "m/0'/0'/0'", "hdmasterkeyid": "0000000000000000000000000000000000000000" }

jeong760 commented 6 years ago

@bonesoul, globaltoken has been modified a paymentprocessor.cs so GetAddressInfo() related issue solved but need to check more for whole source codes related to handling share, transaction, saving the result on the hybrid storage, and stratum connection handling etc.

bonesoul commented 6 years ago

sure, i'm watching the changes.

jeong760 commented 6 years ago

@bonesoul, @globaltoken has been fixed a support a GetAddressInfo() and ValidateAddress() by coin wallet to add a RpcUpdate arg on coin.json config and some source codes. Now everything is working fine with this final version so please update last to your repo.

I am expressing my sincere thanks to @globaltoken to solve and improve many things of CoiniumServ to share his valuable time.

The screenshot webpage_20180314

Regards, John Ahn

jeong760 commented 6 years ago

This has been solved by @globaltoken. Now CoiniumServ works perfectly with Coin wallet version from lower version till to v0.16.0 or higher for specific wallet crores.

@globaltoken has been fixed (I am appreciate @globaltoken very much. thanks)

@jeong760 has been fixed.

Regards, John Ahn

jeong760 commented 6 years ago

@bonesoul

Could you review and merged my PR for this fix? I am operation a Bitcoin, Dogecoin, Globaltoekn and Litecoin pool service on CoiniumServ. after modification everything is working fine and no further error message comes out on the console.

Regards, John Ahn

bonesoul commented 6 years ago

i'll check it out.

jeong760 commented 6 years ago

@bonesoul when do you merged my PR please? and I have a question which code should be modify to implement a Equihash?

bonesoul commented 6 years ago

I'll check it this weekend.

jeong760 commented 6 years ago

@bonesoul and @globaltoken Thank you. and I will open a new PR soon for Equihash after more days check.

flyx2888 commented 6 years ago

Tell me if I'm wrong, but while this new fix works for newer wallets, it breaks support for older wallets. The premise behind this was to check for wallet version and if newer then use getnetworkinfo else for older wallets use getinfo, but right from the get go we have a problem already.

Refer to the folllowing code:

public void Recache()
{
            var Info= _daemonClient.Getnetworkinfo(); //Defined a Variables to get CoinVersion info
            CoinVersion = Info.Version; // CoinVersion is a string with version: 150100
            int version = Int32.Parse("CoinVersion"); // Convert a CoinVersion info to numeric value

    if (version == 150100)   // Compare the value same as condition, then running a GetInfo()

.......

Here in the recache(), it begins by checking for wallet version before it enters an if/else depending on version. See the problem? It is using getnetworkinfo to obtain this version, which most likely will not exsit in older version wallets and thus cause an RpcErrorException: Method not found during pool initialization.

jeong760 commented 6 years ago

@flyx2888 Yes, but it was fixed already before I asked a PR. please refers to following before you write to something you should be checked a code first. and I've tested fully using old wallet before the PR request.

P.S. Good question. and before please check the code that I modified. actually, this added due to suppress a Getinfo() related error message displayed on the console. because Bitcoin v0.16.0 does not support a Getinfo() anymore. so without this, it gives me an errors messages on a console. however, if you have a better solution to do this then please do make a test and open a new PR.

also this code you can find on /src/CoiniumServ/pool/NetworkInfo.cs.

The Method not found message on [Paymentprocessor] it shows on the console due to Global token does not support a Validateaddress() to get a IsMine result. so it also solved to add a "rpcupdate" : true, on coin.json file if wallet higher than v0.16.0. Bitcoin core wallet also deprecated Validateaddress from v0.18.0. IsMine result code will uses a GetAddressInfo() command after that..

PaymentProcessor.cs private bool ValidatePoolAddress(bool newWallet) { try { if(newWallet == true) { var result = _daemonClient.ValidateAddress(_poolConfig.Wallet.Adress); var resultnew = _daemonClient.GetAddressInfo(_poolConfig.Wallet.Adress);

                if (result.IsValid && resultnew.IsMine)
                    return true;

                _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
                return false;
            }
            else
            {
                var result = _daemonClient.ValidateAddress(_poolConfig.Wallet.Adress);

                // make sure the pool central wallet address is valid and belongs to the daemon we are connected to.
                if (result.IsValid && result.IsMine)
                    return true;

                _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
                return false;
            }                               
        }
        catch (Exception e)
        {
            _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message);
            return false;
        }
    }

NetworkInfo.cs public void Recache() {

        var PreInfo = _daemonClient.Getnetworkinfo(); //Defined a Variables to get CoinVersion info
        CoinVersion = PreInfo.Version; // CoinVersion is a string with version: 150100
        int version = Int32.Parse(CoinVersion); // Convert a CoinVersion info to numeric value

        if (version <= 150100)   // Compare the value same as condition, then running a GetInfo()
        // if coin wallet version "less" than or "equal" to 150100 then run the following code, if not got to else if (version >= 160000)

Regards, John Ahn

jeong760 commented 6 years ago

@flyx2888 do you have any problem after I added this? then description better here. I will make and do more test.

flyx2888 commented 6 years ago

Yes, unfortunately. Essentially any coins with wallets that are still using getinfo no longer works. This happens during pool initialization with RpcErrorException: Method not found. Its easy to test, try any coin that still uses getinfo.

Your fix however works perfect with newer wallets that uses getnetworkinfo.

jeong760 commented 6 years ago

@flyx2888 Really? I've run a Litecoin, Dash, Dogecoin, Litecoincash, Bitcoin cash, Mooncoin all of these wallets have a different wallet even some of them less than 150100 but works as well.

Are you sure that Method not found caused by this code modification? please post your server screenshot if so or think.

if (version <= 150100) // Compare the value same as condition, then running a GetInfo() // if coin wallet version "less" than or "equal" to 150100 then run the following code, if not got to else if (version >= 160000)

flyx2888 commented 6 years ago

BTW, I'm not blaming you by any means. But if I'm not mistaken that code breaks older wallets. I don't know when it appeared or who made those changes. It just happens this thread covers that section of code I came across while debugging.

Do those wallets have both getinfo and getnetworkinfo? I notice some coin wallets still have both and those will all obviously work, but for the ones that only uses getinfo, it will not.

jeong760 commented 6 years ago

@flyx2888 it is okay. because I also don't believe and sure that 100% correct in my code. but when I added an if (version <= 150100) // less than or equal after to get a conversion. it works.

As I mentioned earlier I found a bug before I open a PR and it was solved to add above ( version <= 150100)

flyx2888 commented 6 years ago

Okay. Well I will continue to debug and run some further tests. I'll let you know what I come up with if any. Thanks for taking the time to respond.

jeong760 commented 6 years ago

@flyx2888 I will help you if I can so please do not hesitate a post screenshot here first.

flyx2888 commented 6 years ago

Will do. Thanks @jeong760

flyx2888 commented 6 years ago

@jeong760

Here's 2 screenshots. The first is using v2.6.3 source tree with the above-mentioned code.

v2 6 3

The 2nd, is using v2.6.3 source tree with the recache() function from v2.6.2 in src/CoiniumServ/pool/NetworkInfo.cs.

v2 6 2

No other changes were made. Just replaced the recache() function to the prior version. This is using Peercoin version 0.6.2ppc, which has getinfo() ONLY and not getnetworkinfo(). My initial observations were correct. Let's see what you come up with and then we can work on making this work properly for both new and old wallets.

jeong760 commented 6 years ago

@flyx2888 I think this problem caused by Coinwallet version format. Because after recache() I instert a following inorder to converting version string to number to compare for if statement. So if Coinwallet uses a different format like v.0.6.2ppc then it does not convert it to number. But I will check after dinner time

var PreInfo = _daemonClient.Getnetworkinfo(); //Defined a Variables to get CoinVersion info CoinVersion = PreInfo.Version; // CoinVersion is a string with version: 150100 int version = Int32.Parse(CoinVersion); // Convert a CoinVersion info to numeric value

flyx2888 commented 6 years ago

@jeong760

That is quite possible also (I will check it), but going back to my initial observation you will always get RpcErrorException: Method not found by making a call to getnetworkinfo() if that function is not available in the wallet and that is my point. If the wallet only has getinfo() function and not getnetworkinfo(), it will always return an error. Some wallets have both function irrespective of version and will work obviously. So my point is, by calling getnetworkinfo() initially in recache() function to get a version before we even know which method: getinfo() only, getnetworkinfo(), or both does not make sense as it will always fail if getinfo() only is supported.

I will review the rest of your code in the morning when I get a chance. It's already 4am. Let me know your findings when you've had a chance to test. Enjoy dinner.

jeong760 commented 6 years ago

@flyx2888

I am sure that your coin uses a different version name that caused this error. as you see following other coins information it uses a number only. so in order to solve this, you need to find a way to get version info only number.

[NetworkInfo] [Globaltoken] symbol: GLT algorithm: sha256 version: 2010000 protocol: 70003 wallet: 139900 [NetworkInfo] [Litecoin] symbol: LTC algorithm: scrypt version: 150100 protocol: 70015 wallet: 139900 [NetworkInfo] [Litecoincash] symbol: LCC algorithm: sha256 version: 150001 protocol: 70015 wallet: 139900

However, Peercoin return a different version format when issued a getinfo()

 { "version" : "v0.6.2ppc", "protocolversion" : 70001, "walletversion" : 60000, "balance" : 0.00000000, "newmint" : 0.00000000, "stake" : 0.00000000, "blocks" : 8914, "moneysupply" : 10418256.07053900, "timeoffset" : 1, }

Regards, John Ahn

flyx2888 commented 6 years ago

@jeong760

You are correct:

    int version = Int32.Parse(CoinVersion); // Convert a CoinVersion info to numeric value

will cause an error, but you will never get to that point because:

    var PreInfo = _daemonClient.Getnetworkinfo(); //Defined a Variables to get CoinVersion info

will cause an rpc error first since that method doesn't exist for this wallet.

You can test the remainder of recache() function by removing the initial call to getnetworkinfo() and define version as 100500 for example. It will still crap out at some point since the if/else is not encased properly.

This is the current logic flow of recache():

if version is less than or equal to 150100 do getinfo()

else if version is greater than or equal to 160000 do getblockchaininfo()

if/else finished now do getnetworkinfo() getwalletinfo() getmininginfo()

.....

Do you see the problem with that logic flow? We defined version as 100500, which is suppose to do getinfo() only but it will continue on to also do getnetworkinfo(), getwalletinfo(), and getmininginfo() -- subsequently causing further errors. Simply put, there are multiple problems with recache() function.

flyx2888 commented 6 years ago

@jeong760

Let's not bother with versions since most wallets do not follow standards anyways. Try this modified recache() function for src/CoiniumServ/pool/NetworkInfo.cs:

    public void Recache()
    {

        try // read getnetworkinfo() followed by getwalletinfo() based data.
        {
            var info = _daemonClient.GetNetworkInfo();

            // read data.
            CoinVersion = info.Version;
            ProtocolVersion = info.ProtocolVersion;
            Connections = info.Connections;
            Errors = info.Errors;

            try // read getwalletinfo() based data.
            {
                var infoWall = _daemonClient.GetWalletInfo();

                // read data.
                WalletVersion = infoWall.WalletVersion;
            }
            catch (RpcException e)
            {
                _logger.Error("Can not read getwalletinfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }

            // check if our network connection is healthy.
            Healthy = Connections >= 0 && string.IsNullOrEmpty(Errors);
        }
        catch (RpcException e) // catch exception, provide backwards compatability for getinfo() based data.
        {
            //_logger.Error("Can not read getnetworkinfo(), trying getinfo() instead: {0:l}", e.Message); // do not log original error, try getinfo() first.

            try // read getinfo() based data.
            {
                var info = _daemonClient.GetInfo();

                // read data.
                CoinVersion = info.Version;
                ProtocolVersion = info.ProtocolVersion;
                WalletVersion = info.WalletVersion;
                Testnet = info.Testnet;
                Connections = info.Connections;
                Errors = info.Errors;

                // check if our network connection is healthy.
                Healthy = Connections >= 0 && string.IsNullOrEmpty(Errors);
            }
            catch (RpcException ee)
            {
                _logger.Error("Can not read getinfo(): {0:l}", ee.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }
        }

        try // read getmininginfo() based data.
        {
            var miningInfo = _daemonClient.GetMiningInfo();

            // read data.
            Hashrate = miningInfo.NetworkHashPerSec;
            Difficulty = miningInfo.Difficulty;
            Round = miningInfo.Blocks + 1;
            if (!Testnet)
                Testnet = miningInfo.Testnet;
        }
        catch (RpcException e)
        {
            _logger.Error("Can not read getmininginfo(): {0:l}", e.Message);
            Hashrate = 0;
            Difficulty = 0;
            Round = -1;
            Healthy = false; // set healthy status to false as we couldn't get a reply.
        }

        try // read getblocktemplate() based data.
        {
            var blockTemplate = _daemonClient.GetBlockTemplate(_poolConfig.Coin.Options.BlockTemplateModeRequired);
            Reward = (UInt64)blockTemplate.Coinbasevalue / 100000000; // coinbasevalue is in satoshis, convert it to actual coins.
        }
        catch (RpcException e)
        {
            _logger.Error("Can not read getblocktemplate(): {0:l}", e.Message);
            Reward = 0;
        }
    }
jeong760 commented 6 years ago

@flyx2888
First of all, you have modified a code to get wallet version not a version of coin daemon. I also think that method but never tested. and the other still get necessary info from Getinfo().

flyx2888 commented 6 years ago

@jeong760

Version or no version, wallet or coin daemon, it doesn't matter. It's not needed and trivial at best. I ignored it altogether and just work with current methods and work my way back if need be.

Let me know if the modified code works with your globaltoken. Its's fine for all the coins that were broken on my end, but I will continue to make some further minor tweaks as I see them.

jeong760 commented 6 years ago

@flyx2888. I am not sure those information not necessary but it used by web frontend to display a pool information. so if you delete it has an probelm to calculate or display related with payment or PPLNS round.

jeong760 commented 6 years ago

@flyx2888 I will check above code but does it also surpressed a message about Getinfo() on the console if coinwallet version v0.16.0? Because bitcoin wallet v0.16.0 does not support a Getinfo() anymore so I think you will get the message every minutes basis..

jeong760 commented 6 years ago

@bonesoul and @flyx2888 I was reopened this case due to serious bug on my previous PR so after I've tested will open another fixed PR for this.

flyx2888 commented 6 years ago

@jeong760

Okay. I think you need to just test it first. It's a quick change of 1 function in 1 file only. I did not change it's behavior. I only eliminated the need to look for a version then branch off on an if/else. By default it assumes all wallets are newer and if it can't proceed it works backwards. That's all.

jeong760 commented 6 years ago

Dear flyx2888,

Yes I hope your solution works on my pool. I am not a programmer so mu knowledge of programming is weaker than you and authors of CoiniumServ and other contributors

But want to maintaining and improved a CoiniumServ.

Regards, John Ahn -----Original Message----- From: "flyx2888"notifications@github.com To: "bonesoul/CoiniumServ"CoiniumServ@noreply.github.com; Cc: "John Ahn"jeong760@naver.com; "Mention"mention@noreply.github.com; Sent: 2018-04-16 (월) 13:24:49 Subject: Re: [bonesoul/CoiniumServ] CoiniumServ needs to add a new command for coin wallet v0.16.0 instead of use a getinfo() (#975)

@jeong760 Okay. I think you need to just test it first. It's a quick change of 1 function in 1 file only. I did not change it's behavior. I only eliminated the need to look for a version then branch off on an if/else. By default it assumes all wallets are newer and if it can't proceed it works backwards. That's all. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bonesoul commented 6 years ago

@jeong760 sure waiting for your PR.

jeong760 commented 6 years ago

@flyx2888

It is working but need to check and modification for error handling messages. So I will update it soon after more days test.

Regards, John Ahn

flyx2888 commented 6 years ago

@jeong760

Good to hear. What error handling message? Here's a slight modification to Healthy status in the same function. Some wallets return an info only alert via error message, which does not affect the health of the pool so we keep the Healthy status as normal and not down.

    public void Recache()
    {

        try // read getnetworkinfo() followed by getwalletinfo() based data.
        {
            var info = _daemonClient.GetNetworkInfo();

            // read data.
            CoinVersion = info.Version;
            ProtocolVersion = info.ProtocolVersion;
            Connections = info.Connections;
            Errors = info.Errors;

            try // read getwalletinfo() based data.
            {
                var infoWall = _daemonClient.GetWalletInfo();

                // read data.
                WalletVersion = infoWall.WalletVersion;
            }
            catch (RpcException e)
            {
                _logger.Error("Can not read getwalletinfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }

            // check if our network connection is healthy. info: based errors are warnings only so ignore.
            Healthy = Connections >= 0 && (string.IsNullOrEmpty(Errors) || Errors.Contains("Info:"));
        }
        catch (RpcException e) // catch exception, provide backwards compatability for getinfo() based data.
        {
            //_logger.Error("Can not read getnetworkinfo(), trying getinfo() instead: {0:l}", e.Message); // do not log original error, try getinfo() first.

            try // read getinfo() based data.
            {
                var info = _daemonClient.GetInfo();

                // read data.
                CoinVersion = info.Version;
                ProtocolVersion = info.ProtocolVersion;
                WalletVersion = info.WalletVersion;
                Testnet = info.Testnet;
                Connections = info.Connections;
                Errors = info.Errors;

                // check if our network connection is healthy. info: based errors are warnings only so ignore.
                Healthy = Connections >= 0 && (string.IsNullOrEmpty(Errors) || Errors.Contains("Info:"));
            }
            catch (RpcException ee)
            {
                _logger.Error("Can not read getinfo(): {0:l}", ee.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }
        }

        try // read getmininginfo() based data.
        {
            var miningInfo = _daemonClient.GetMiningInfo();

            // read data.
            Hashrate = miningInfo.NetworkHashPerSec;
            Difficulty = miningInfo.Difficulty;
            Round = miningInfo.Blocks + 1;
            if (!Testnet)
                Testnet = miningInfo.Testnet;
        }
        catch (RpcException e)
        {
            _logger.Error("Can not read getmininginfo(): {0:l}", e.Message);
            Hashrate = 0;
            Difficulty = 0;
            Round = -1;
            Healthy = false; // set healthy status to false as we couldn't get a reply.
        }

        try // read getblocktemplate() based data.
        {
            var blockTemplate = _daemonClient.GetBlockTemplate(_poolConfig.Coin.Options.BlockTemplateModeRequired);
            Reward = (UInt64)blockTemplate.Coinbasevalue / 100000000; // coinbasevalue is in satoshis, convert it to actual coins.
        }
        catch (RpcException e)
        {
            _logger.Error("Can not read getblocktemplate(): {0:l}", e.Message);
            Reward = 0;
        }
    }
jeong760 commented 6 years ago

@flyx2888

There include a several times of error catch condition so Visual studio displayed an error message before compile. so I was change then like following it compile and works with any errors. so not sure I am correctly do.

catch (RpcException e) { _logger.Error("Can not read getwalletinfo(): {0:l}", e.Message);

catch (RpcException b) --> (RpcException) and make description { // _logger.Error("Can not read getnetworkinfo(), trying getinfo() instead: {0:l}", e.Message); }

catch (RpcException c) { _logger.Error("Can not read getmininginfo(): {0:l}", c.Message); }

Regards, John Ahn

jeong760 commented 6 years ago

@flyx2888
I've configured a StrongHands and Peercoin on my pool because they uses a different version name of them. after modification a code as you wrote above it works. but need to check more days.