예제 #1
0
        // Checks the current balance of the masternode
        static public bool checkMasternodeBalance()
        {
            if (Config.workerOnly)
            {
                return(false);
            }

            // First check if the block processor is running
            if (blockProcessor.operating == true)
            {
                if (blockChain.getLastBlockNum() > 2)
                {
                    IxiNumber nodeBalance = walletState.getWalletBalance(walletStorage.getPrimaryAddress());
                    if (!isMasterNode())
                    {
                        if (nodeBalance >= ConsensusConfig.minimumMasterNodeFunds)
                        {
                            Logging.info(string.Format("Your balance is more than the minimum {0} IXIs needed to operate a masternode. Reconnecting as a masternode.", ConsensusConfig.minimumMasterNodeFunds));
                            convertToMasterNode();
                        }
                    }
                    else
                    if (nodeBalance < ConsensusConfig.minimumMasterNodeFunds)
                    {
                        if (Config.disableMiner == false || CoreConfig.isTestNet)
                        {
                            if (Config.disableMiner)
                            {
                                miner.pause = true;
                            }
                            if (!isWorkerNode())
                            {
                                Logging.error(string.Format("Your balance is less than the minimum {0} IXIs needed to operate a masternode. Reconnecting as a worker node.",
                                                            ConsensusConfig.minimumMasterNodeFunds));
                                convertToWorkerNode();
                            }
                        }
                        else
                        {
                            Logging.error(string.Format("Your balance is less than the minimum {0} IXIs needed to operate a masternode. Reconnecting as a client node.",
                                                        ConsensusConfig.minimumMasterNodeFunds));
                            convertToClientNode();
                        }
                        return(false);
                    }
                }
            }
            // Masternode has enough IXIs to proceed
            return(true);
        }
예제 #2
0
        // Checks the current balance of the masternode
        static public bool checkMasternodeBalance()
        {
            if (Config.workerOnly)
            {
                return(false);
            }

            // First check if the block processor is running
            if (blockProcessor.operating == true)
            {
                ulong last_block_num = blockChain.getLastBlockNum();
                if (last_block_num > 2)
                {
                    IxiNumber nodeBalance = walletState.getWalletBalance(walletStorage.getPrimaryAddress());
                    if (!isMasterNode())
                    {
                        if (nodeBalance >= ConsensusConfig.minimumMasterNodeFunds)
                        {
                            if (lastMasterNodeConversionBlockNum != last_block_num)
                            {
                                lastMasterNodeConversionBlockNum = last_block_num;
                                Logging.info(string.Format("Your balance is more than the minimum {0} IXIs needed to operate a masternode. Reconnecting as a masternode.", ConsensusConfig.minimumMasterNodeFunds));
                                convertToMasterNode();
                            }
                        }
                    }
                    else
                    if (nodeBalance < ConsensusConfig.minimumMasterNodeFunds)
                    {
                        if (!isWorkerNode())
                        {
                            Logging.error(string.Format("Your balance is less than the minimum {0} IXIs needed to operate a masternode. Reconnecting as a worker node.",
                                                        ConsensusConfig.minimumMasterNodeFunds));
                            convertToWorkerNode();
                        }
                        return(false);
                    }
                }
            }
            // Masternode has enough IXIs to proceed
            return(true);
        }