Esempio n. 1
0
        public async Task <List <Deposit> > Startup()
        {
            try
            {
                //var blockPeriod = 5 * 60 * 20 * 30;  // Amount of blocks to scan for events
                var deposits = new List <Deposit>();

                try
                {
                    currentBlock  = new HexBigInteger((await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync()).Value - 5);
                    startupFilter = logDepositEvent.CreateFilterInput(new BlockParameter(new HexBigInteger(currentBlock.Value - currentBlock.Value + 1)), new BlockParameter(currentBlock));
                    startupLog    = await logDepositEvent.GetAllChanges <LogDepositEvent>(startupFilter);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                foreach (var d in startupLog)
                {
                    var deposit = new Deposit();
                    deposit.TargetWallet = d.Event.Destination;
                    deposit.Asset        = d.Event.Symbol;
                    deposit.Quantity     = Web3Geth.Convert.FromWei(d.Event.Value);
                    deposit.TxHash       = d.Log.TransactionHash;
                    currentBlock         = d.Log.BlockNumber;
                    deposits.Add(deposit);
                }

                return(deposits);
            }
            catch (Exception e)
            {
                Console.WriteLine("Ethereum Connector Startp Failed: " + e.ToString());
            }

            return(await Task.FromResult((List <Deposit>) null));
        }
Esempio n. 2
0
        public IEnumerator SendRequest(Nethereum.RPC.Eth.DTOs.NewFilterInput newFilterInput)
        {
            var request = _ethNewFilter.BuildRequest(newFilterInput);

            yield return(SendRequest(request));
        }