These are chat archives for Nethereum/Nethereum

4th
Jun 2018
Juan Blanco
@juanfranblanco
Jun 04 2018 11:25
@p0isoNz_twitter no if you are not using the hdwallet
abhishek
@triston_abhi_twitter
Jun 04 2018 13:56
@juanfranblanco
await con.GetFunction("checkProof").CallAsync<bool>(val);
This method suddenly stop working today.
It gives me error like "EdjCase.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) --->"
I am using ropsten.infura.io as url
And main issue is it sends transactions but not able to verify.
p0isoN
@p0isoNz_twitter
Jun 04 2018 14:22
@juanfranblanco thanks. Do you happen to know any documentation on erc20 tokens and handling them?
Psilon
@Pzixel
Jun 04 2018 15:45
Hello @juanfranblanco
I'd like to ask how can I implement caching
I need to get all events starting from some block and keep it
ChinhP
@Chinh-P
Jun 04 2018 15:48
@triston_abhi_twitter if you're using 451 you'll need to explicitly assign the security protocol (servicepointmanager.securityprotocol = securityprotocoltype.tls12)
credit to @EnigmaticUnreal_twitter
@Pzixel imho, I think just scan and save it to your offline database. just like some ether scanning site did.
Psilon
@Pzixel
Jun 04 2018 15:50
I don't see how it could be implemented
for example I know that I stopped the service at monday, 12:00
the latest block was 0xfdf1
then I run it
I have to know that events occured since
Psilon
@Pzixel
Jun 04 2018 18:30
Okay, I implemented it
public async Task RunAsync(CancellationToken cancellationToken)
{
    const int pollingTimeoutMs = 5000;
    var block = await _blockStore.GetBlockAsync();
    var season = await _seasonFactory.GetLastSeasonAsync();
    var logger = _contextlessLogger.ForContext(nameof(Season), season.Address);
    var requestCreatedEvent = season.GetRequestCreatedEvent();
    while (!cancellationToken.IsCancellationRequested)
    {
        var filter = await requestCreatedEvent.CreateFilterAsync(new BlockParameter(block));
        var eventLogs = await requestCreatedEvent.GetAllChanges<RequestCreatedEventDto>(filter);
        if (eventLogs.Count == 0)
        {
            logger.Verbose("No new entries. Sleeping for {pollingTimeoutMs}ms", pollingTimeoutMs);
            await Task.Delay(pollingTimeoutMs, cancellationToken);
        }
        else
        {
            logger.Debug("Found {newItemsCount} new items. Getting new requests", eventLogs.Count);

            .. doing some stuff here

            await Task.WhenAll(tasksToUpdate);
            block = new HexBigInteger(eventLogs.Last().Log.BlockNumber.Value + 1);
            await _blockStore.SaveBlockAsync(block);
            logger.Debug("All requests was indexed");
        }
    }
}
Juan Blanco
@juanfranblanco
Jun 04 2018 19:03
@triston_abhi_twitter that is a rather old build. Are you using .net451?
@Pzixel yeah you could do that :)
Psilon
@Pzixel
Jun 04 2018 19:05
:)
Stef Heyenrath
@StefH
Jun 04 2018 19:06
@juanfranblanco Why does the FIlterLog not include information about the Block itself? If I want to know the timestamp for example, I need to call _web3.Eth.Blocks.GetBlockWithTransactionsByHash.SendRequestAsync(blockhash); ?
Juan Blanco
@juanfranblanco
Jun 04 2018 19:06
@triston_abhi_twitter ignore it @ChinhPLQ has answered
Psilon
@Pzixel
Jun 04 2018 19:09
@juanfranblanco I also wondering about eventLogs ordering
is it guaranteed that eventLogs.Last().Log.BlockNumber is the maximum block from the entire list?
Juan Blanco
@juanfranblanco
Jun 04 2018 19:09
Psilon
@Pzixel
Jun 04 2018 19:10
can it be that eventLogs.Last().Log.BlockNumber != eventLogs.Max(x=>x.Log.BlockNumber) ?
Juan Blanco
@juanfranblanco
Jun 04 2018 19:13
well for that reason you have EventLogBlockNumberTransactionIndexComparer
and the FilterLogBlockNumberTransactionIndexComparer
check the EventLogSortingTests and the FilterLogSortingTests
Psilon
@Pzixel
Jun 04 2018 19:16
Ok i see
Should I run them manually or they run when fetching info from bc?
Juan Blanco
@juanfranblanco
Jun 04 2018 19:17
no you need to run then manually
Psilon
@Pzixel
Jun 04 2018 19:17
Well, I'l just use Max then
thank you
:)
Juan Blanco
@juanfranblanco
Jun 04 2018 19:17
oh.. but remember that blocks have transactions
Psilon
@Pzixel
Jun 04 2018 19:17
I don't actually need to sort them. I just need to know at which block I ended my scan last time
Juan Blanco
@juanfranblanco
Jun 04 2018 19:17
ah..
Psilon
@Pzixel
Jun 04 2018 19:18
you can see the codee
Juan Blanco
@juanfranblanco
Jun 04 2018 19:18
this is to process them in order of event
Psilon
@Pzixel
Jun 04 2018 19:18
I store the block I processed last time and watch if anything new came
I don't need to keep an order, I just need a bunch of them)
Juan Blanco
@juanfranblanco
Jun 04 2018 19:18
:)
Psilon
@Pzixel
Jun 04 2018 19:18
so ty for explaining it
I just didn't want to reevaluate blocks I already done
Juan Blanco
@juanfranblanco
Jun 04 2018 19:19
yep same pattern but when you need them in order
Psilon
@Pzixel
Jun 04 2018 19:19
If you see I pass them into Task.WhenAll anyway
Juan Blanco
@juanfranblanco
Jun 04 2018 19:19
although you may want to validate for reorgs
public bool Removed { get; set; } in the FilterLog
Psilon
@Pzixel
Jun 04 2018 19:22
What is that?
Mainly a flag if the log has been removed due to a reorg
Psilon
@Pzixel
Jun 04 2018 22:24
@juanfranblanco it's a bit uncommon question
and I'm not sure if I should ask you
but
do you know anything about performance boost in solidity?
I have a smart contract but it's very very slow
i can only get 2tx/sec
can you elaborate, please?
I just don't know how can I profile or speedup it
Psilon
@Pzixel
Jun 04 2018 22:30
any advice? I literally hit the wall with my head.