Ejemplo n.º 1
0
        }//end of public async void UpdateStakingInformation()

        /// <summary>
        /// Starts Staking
        /// </summary>
        /// <param name="wallet">Wallet To Enable</param>
        /// <param name="password">Wallet Password</param>
        public async Task <bool> StartStaking(string wallet, string password)
        {
            if (!WalletAccounts.ContainsKey(wallet))
            {
                Logger.Error($"Node '{Name}' ({Address}:{Port}), Wallet Not Found, Run 'UpdateStaticData()' Manually"); return(false);
            }

            //todo: Implement
            throw new NotImplementedException("IMPLEMENT ME BITCH!!");

            //return true;
        }//end of public async void StartStaking(string wallet, string password)
Ejemplo n.º 2
0
        //Obtains Data that is NOT likely to change!
        public async void UpdateStaticData()
        {
            //are we connected??
            if (ConnectionMethod == ConnectionType.Disconnected)
            {
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}), Aborting 'Static Data' Update.  Internal State Is Disconnected!");
                return;
            } //end of if(ConnectionMethod == ConnectionType.Disconnected)

            try
            {
                GetWalletFilesResponse filesData = await restClient.GetWalletFiles();

                if (filesData == null)
                {
                    errorFsInfo = true; //an error occured, this data is relied upon in the "RefreshNodeData" Method
                    logger.LogInformation(
                        $"Node '{Name}' ({Address}:{Port}), An Error Occured When Getting Node File Information!");
                }
                else
                {
                    WalletPath  = filesData.walletsPath;
                    WalletFiles = new List <string>(filesData.walletsFiles);

                    foreach (string wallet in WalletFiles)
                    {
                        //parse MyWallet.wallet.json  to "MyWallet"
                        string walletName = wallet.Substring(0, wallet.IndexOf("."));

                        //Get a list of accounts
                        List <string> walletAccounts = await restClient.GetWalletAccounts(walletName);

                        if (walletAccounts == null)
                        {
                            logger.LogInformation(
                                $"An Error Occured When Trying To Get Wallet Accounts For Wallet '{walletName}'");
                        }

                        if (walletAccounts.Count > 0)
                        {
                            //Are there already present wallets? if so overwrite the data, if not then lets add a new record
                            if (WalletAccounts.ContainsKey(walletName))
                            {
                                WalletAccounts[walletName] = walletAccounts;
                            }
                            else
                            {
                                WalletAccounts.Add(walletName, walletAccounts);
                            }
                        } //end of if(walletAccounts.Count > 0)
                    }     //end of foreach

                    errorFsInfo = false;
                } //end of if-else if (filesData == null)
            }
            catch (HttpRequestException ex) //API is not accessible or responding
            {
                OnDisconnected(Address, Port);
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}) Something Happened & The Node API Is Not Accessible", ex);
            }
            catch (Exception ex)
            {
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}) An Error Occured When Polling For Static Data!", ex);
            } //end of try-catch
        }     //end of private async void GetStaticData()