예제 #1
0
        public IActionResult PublicHeight()
        {
            var bnr = _bsm.GetPublicBlockNr().TryGetBlockNumber();

            if (bnr <= 0)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(StatusCode(StatusCodes.Status200OK, bnr));
        }
예제 #2
0
        protected override async Task Process()
        {
            var bn    = _bsm.GetPublicBlockNr();
            var delay = 100;

            if (bn != null && (DateTime.UtcNow - bn.TimeStamp).TotalSeconds < _cfg.publicRequestDelay)
            {
                var timeUntilNextExecution = (_cfg.publicRequestDelay * 1000) - (DateTime.UtcNow - bn.TimeStamp).TotalMilliseconds;
                if (timeUntilNextExecution > delay)
                {
                    delay = (int)timeUntilNextExecution;
                }
            }

            await Task.Delay(delay);

            await _bsm.TryUpdatePublicBlockHeight();
        }