Calling GetBlockWithTransactionsByNumber asynchronoulsy from within a ProcessorForContract frequently returns NULLs. If I execute the following:
HexBigInteger blockNumber = new HexBigInteger(sl.Log.BlockNumber); blockFromChain = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockNumber); I very often get a NULL value in blockFromChain but if I select "set next statement" from within the VS debugger and selects the async call again it will indeed return a block. To me it seems that the async call doesn't wait 'til the actual block has been returned. The reason I make a GetBlockWithTransactionsByNumber from within my (Create)ProcessorForContract async method is that I need to get the actual block timestamp as my TransferEventDTO doesn't include a timestamp in the .Log or .Event objects. If there's a better way to get the timestamp I'm all ears :) The async method I'm referring to looks like:
var logsProcessor = web3.Processing.Logs.CreateProcessorForContract<TransferEventDTO>(ContractAddress, (Func<EventLog<TransferEventDTO>, Task>)(async sl => { HexBigInteger blockNumber = new HexBigInteger(sl.Log.BlockNumber); blockFromChain = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockNumber); code goes here... } The application is a .Net 7 C# console app.
Many thanks in advance!