public async Task <IActionResult> GetEOSActionsAsync([FromServices] NodeApiInvoker nodeApiInvoker, GetEOSActionsRequest request, CancellationToken cancellationToken) { var apiActions = await nodeApiInvoker.GetActionsAsync(request.Account, request.Skip, request.Take, cancellationToken); var responseData = apiActions.actions.Select(x => new GetEOSActionsResponse() { act = x.action_trace.act, time = x.action_trace.block_time }); return(ApiResult(responseData)); }
public void GetRaised(KyubeyContext db, ILogger logger, NodeApiInvoker nodeApiInvoker, TokenRepositoryFactory tokenRepositoryFactory) { try { var tokenRepository = tokenRepositoryFactory.CreateAsync("en").Result; foreach (var x in db.Tokens .Where(x => x.HasIncubation && x.HasContractExchange) .ToList()) { var token = tokenRepository.GetSingle(x.Id); if (DateTime.UtcNow < TimeZoneInfo.ConvertTimeToUtc(token.Incubation.Begin_Time ?? DateTime.MinValue)) { continue; } if (DateTime.UtcNow > TimeZoneInfo.ConvertTimeToUtc(token.Incubation.DeadLine)) { continue; } var depot = token.Basic.Contract.Depot ?? token.Basic.Contract.Pricing ?? token.Basic.Contract.Transfer; if (string.IsNullOrWhiteSpace(depot) || token.Basic.Contract_Exchange_Info == null) { continue; } var seq = GetOrCreateRaisedSeq(token.Id, db); logger.LogInfo($"Current incubator {token.Id} seq is " + seq); var ret = nodeApiInvoker.GetActionsAsync(depot, seq).Result; if (ret.actions.Count() == 0) { logger.LogInfo($"No new action in incubator {token.Id}"); } if (ret.actions != null) { foreach (var act in ret.actions) { try { logger.LogInfo($"Handling incubator {token.Id} action log pos={act.account_action_seq}, act={act.action_trace.act.name}"); switch (act.action_trace.act.name) { case "transfer": { var transferData = act.action_trace.act.data; if ((string)transferData.memo == token.Basic.Contract_Exchange_Info.Buy_Memo && ((string)transferData.quantity).GetTokenAssetType() == "EOS") { var quantity = ((string)transferData.quantity).GetTokenAssetValue(); HandleRaiseLogAsync(db, (int)act.account_action_seq, token.Id, depot, (string)transferData.from, (string)transferData.to, quantity, act.action_trace.block_time).Wait(); HandleRaiseCountAsync(db, token.Id, TimeZoneInfo.ConvertTimeToUtc(token.Incubation.Begin_Time ?? DateTime.MinValue), TimeZoneInfo.ConvertTimeToUtc(token.Incubation.DeadLine)).Wait(); } else { continue; } } break; default: continue; } } catch (Exception ex) { logger.LogError($"incubator token: {token.Id} req: {seq} error: {token.Id} {seq} {ex.ToString()}"); } } } seq += ret.actions.Count(); UpdateRaisedSeq(token.Id, seq, db); } } catch (Exception e) { logger.LogError("Sync Exception:" + JsonConvert.SerializeObject(e)); } }