private async Task <IActionResult> GetCoinAdapter(string argument, Func <string, Task <ICoin> > recieveFunc) { if (string.IsNullOrEmpty(argument)) { return(BadRequest("identifier is missing")); } ICoin coinAdapter = await recieveFunc(argument);//(id); if (coinAdapter == null) { return(NotFound()); } var result = new CoinResult() { AdapterAddress = coinAdapter.AdapterAddress, Blockchain = coinAdapter.Blockchain, BlockchainDepositEnabled = coinAdapter.BlockchainDepositEnabled, ContainsEth = coinAdapter.ContainsEth, ExternalTokenAddress = coinAdapter.ExternalTokenAddress, Id = coinAdapter.Id, Multiplier = coinAdapter.Multiplier, Name = coinAdapter.Name }; return(Ok(result)); }
private void Run(int n, int f) { for (var i = 0; i < n; ++i) { _broadcasters[i].InternalRequest( new ProtocolRequest <CoinId, object?>(_resultInterceptors[i].Id, (CoinId)_coins[i].Id, null) ); } for (var i = 0; i < n; ++i) { _coins[i].WaitFinish(); } _deliveryService.WaitFinish(); var results = new CoinResult[n]; for (var i = 0; i < n; ++i) { Assert.IsTrue(_coins[i].Terminated, $"protocol {i} did not terminate"); Assert.AreEqual(_resultInterceptors[i].ResultSet, 1, $"protocol {i} emitted result not once"); results[i] = _resultInterceptors[i].Result; } Assert.AreEqual(1, results.Distinct().Count(), "all guys should get same coin"); }
private ulong GetNonceFromCoin(CoinResult result) { var res = new byte[8]; for (var i = 0; i < result.RawBytes.Length; ++i) { res[i % 8] ^= result.RawBytes[i]; } return(res.AsReadOnlySpan().ToUInt64()); }
static public void generateCoins() { // Get the upper limit for the coins int upperLimit = Helper.GetIntFromUser( "Enter the upper limit in GP: "); // Generate the result using the upper limit CoinResult result = coinGen.GenerateCoins(upperLimit); // Print out the result Console.WriteLine(result); }