コード例 #1
0
        /// <summary>
        /// Begins blockchain validation for the won bets.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="match"></param>
        private void OnMatchEnd(int id, Match match)
        {
            Team team = teamController.GetTeam(id);

            match.Winner = team;
            match.Held   = true;
            matchController.EditMatch(match);
            Thread.Sleep(1500);
            List <User> usersWithWonBets = userController.GetBetsOnUserOnMatch(match);

            Console.WriteLine($"GZ {team.Name} med jeres win");
            BlockchainController bctr = new BlockchainController();

            if (bctr.CheckBets(usersWithWonBets))
            {
                foreach (User user in usersWithWonBets)
                {
                    foreach (Bet bet in user.Bets)
                    {
                        user.Account.Balance = user.Account.Balance + (bet.Amount * bet.Odds);
                        userController.UpdateAccount(user);
                        bet.Verified = true;
                        userController.UpdateVerifiedOnBet(bet);
                    }
                }
            }
            Thread.Sleep(100000);
        }
コード例 #2
0
 public BatchController(BlockchainController blockchainController, ChaumianCoinJoinController chaumianCoinJoinController, HomeController homeController, OffchainController offchainController, Global global)
 {
     BlockchainController       = blockchainController;
     ChaumianCoinJoinController = chaumianCoinJoinController;
     HomeController             = homeController;
     OffchainController         = offchainController;
     Global = global;
 }
コード例 #3
0
    public async Task <IActionResult> GetSynchronizeAsync([FromQuery, Required] string bestKnownBlockHash, [FromQuery, Required] int maxNumberOfFilters, [FromQuery] string?estimateSmartFeeMode = nameof(EstimateSmartFeeMode.Conservative))
    {
        bool estimateSmartFee     = !string.IsNullOrWhiteSpace(estimateSmartFeeMode);
        EstimateSmartFeeMode mode = EstimateSmartFeeMode.Conservative;

        if (estimateSmartFee)
        {
            if (!Enum.TryParse(estimateSmartFeeMode, ignoreCase: true, out mode))
            {
                return(BadRequest("Invalid estimation mode is provided, possible values: ECONOMICAL/CONSERVATIVE."));
            }
        }

        if (!uint256.TryParse(bestKnownBlockHash, out var knownHash))
        {
            return(BadRequest($"Invalid {nameof(bestKnownBlockHash)}."));
        }

        (Height bestHeight, IEnumerable <FilterModel> filters) = Global.IndexBuilderService.GetFilterLinesExcluding(knownHash, maxNumberOfFilters, out bool found);

        var response = new SynchronizeResponse {
            Filters = Enumerable.Empty <FilterModel>(), BestHeight = bestHeight
        };

        if (!found)
        {
            response.FiltersResponseState = FiltersResponseState.BestKnownHashNotFound;
        }
        else if (!filters.Any())
        {
            response.FiltersResponseState = FiltersResponseState.NoNewFilter;
        }
        else
        {
            response.FiltersResponseState = FiltersResponseState.NewFilters;
            response.Filters = filters;
        }

        response.CcjRoundStates = ChaumianCoinJoinController.GetStatesCollection();

        if (estimateSmartFee)
        {
            try
            {
                response.AllFeeEstimate = await BlockchainController.GetAllFeeEstimateAsync(mode);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }

        response.ExchangeRates = await OffchainController.GetExchangeRatesCollectionAsync();

        response.UnconfirmedCoinJoins = ChaumianCoinJoinController.GetUnconfirmedCoinJoinCollection();

        return(Ok(response));
    }
コード例 #4
0
        static void Main()
        {
            var blockchainController = new BlockchainController();
            var controller           = new MainController(blockchainController);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(controller));
        }
コード例 #5
0
        private static void RunCreateNewChain()
        {
            if (activeWallet == null)
            {
                Console.WriteLine("No active wallet. Open a wallet first.");
                return;
            }

            BlockchainController controller = new BlockchainController();

            controller.CreateNewChain(activeWallet.Address);
            Console.WriteLine("New chain created.");
        }
コード例 #6
0
        private static void RunRebuildIndex()
        {
            BlockchainController controller = new BlockchainController();
            var response = controller.RebuildIndex();

            if (response.Code == "1")
            {
                Console.WriteLine(JsonConvert.SerializeObject(response.Data));
            }
            else
            {
                Console.WriteLine(response.Message);
            }
        }
コード例 #7
0
 public BlockchainControllerTests()
 {
     _blockchainServiceMock = new Mock <IBlockchainService>();
     _blockchainController  = new BlockchainController(_blockchainServiceMock.Object);
 }
コード例 #8
0
        private static void RunDeleteChain()
        {
            BlockchainController controller = new BlockchainController();

            controller.DeleteLocalChain();
        }
コード例 #9
0
 public async Task <IActionResult> GetAllFeesV3Async([FromQuery, Required] string estimateSmartFeeMode)
 => await BlockchainController.GetAllFeesAsync(estimateSmartFeeMode);
コード例 #10
0
 public LegacyController(BlockchainController blockchainController, OffchainController offchainController)
 {
     BlockchainController = blockchainController;
     OffchainController   = offchainController;
 }