예제 #1
0
 public Erc20BalanceIndexingJobFactory(
     IErc20BalanceIndexingService indexingService,
     ILog logger)
 {
     _indexingService = indexingService;
     _logger          = logger;
 }
예제 #2
0
        public Erc20BalanceIndexingActor(
            IErc20BalanceIndexingService indexingService,
            ILog logger,
            ulong startFrom)
        {
            _indexingService = indexingService;
            _logger          = logger;
            _startFrom       = startFrom;

            ReceiveAsync <Messages.Erc20BalanceIndexingActor.IndexBlockMessage>(async(message) =>
            {
                var sender      = Sender;
                var blockNumber = message.BlockNumber;
                await _indexingService.IndexBlockAsync(blockNumber, Version);

                await _logger.WriteInfoAsync
                (
                    nameof(Erc20BalanceIndexingJob),
                    nameof(ReceiveAsync),
                    "Block balances indexed",
                    $"Indexed balances of block {blockNumber}.",
                    DateTime.UtcNow
                );

                sender.Tell(new Success(true));
            });
        }
예제 #3
0
 public Erc20BalanceIndexingJob(
     IErc20BalanceIndexingService indexingService,
     ILog logger,
     ulong startFrom)
 {
     _indexingService = indexingService;
     _logger          = logger;
     _startFrom       = startFrom;
 }
예제 #4
0
        public Erc20BalanceIndexingActorDispatcher(
            IErc20BalanceIndexingService indexingService,
            ILog logger,
            ulong startFrom,
            IErc20BalanceIndexingActorFactory erc20BalanceIndexingActorFactory)
        {
            _indexingService = indexingService;
            _logger          = logger;
            _startFrom       = startFrom;

            _erc20BalanceIndexingActor = erc20BalanceIndexingActorFactory.Build(Context, "erc20BalanceIndexingActor");

            ReceiveAsync <Messages.Common.DoIterationMessage>(async(message) =>
            {
                var nextBlockToIndex = await _indexingService.GetNextBlockToIndexAsync(_startFrom);
                if (nextBlockToIndex.HasValue)
                {
                    await _erc20BalanceIndexingActor.Ask(
                        Messages.Erc20BalanceIndexingActor.CreateIndexBlockMessage(nextBlockToIndex.Value), TimeSpan.FromSeconds(30));
                }

                Self.Tell(Messages.Common.CreateDoIterationMessage());
            });
        }