/// <summary> /// Notifies message author(s) about message processing result /// </summary> /// <param name="result">Result message</param> public static void OnMessageProcessResult(this AlphaContext context, ResultMessage result) { if (result == null) { return; } if (context == null) { throw new ArgumentNullException(nameof(context)); } var signatures = result.OriginalMessage.Signatures; //unwrap if it is RequestQuantum if (result.OriginalMessage.Message is RequestQuantum) { signatures = ((RequestQuantum)result.OriginalMessage.Message).RequestEnvelope.Signatures; } var envelope = result.CreateEnvelope(); for (var i = 0; i < signatures.Count; i++) { var accountToNotify = signatures[i]; context.Notify(accountToNotify.Signer, envelope); } }
/// <summary> /// Sends the message to the account /// </summary> /// <param name="account">Target account</param> /// <param name="envelope">Message to send</param> public static void Notify(this AlphaContext context, RawPubKey account, MessageEnvelope envelope) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context.ExtensionsManager.BeforeNotify(account, envelope); if (context.ConnectionManager.TryGetConnection(account, out AlphaWebSocketConnection connection)) { Task.Factory.StartNew(async() => await connection.SendMessage(envelope)).Unwrap(); } }
/// <summary> /// Sends the message to all connected auditors /// </summary> /// <param name="envelope">Message to send</param> public static void NotifyAuditors(this AlphaContext context, MessageEnvelope envelope) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context.ExtensionsManager.BeforeNotifyAuditors(envelope); var auditors = context.ConnectionManager.GetAuditorConnections(); for (var i = 0; i < auditors.Count; i++) { var auditor = auditors[i]; Task.Factory.StartNew(async() => await auditor.SendMessage(envelope)).Unwrap(); } }
private RawPubKey GetMessageAccount(AlphaContext context) { var originalEnvelope = ResultMessage.OriginalMessage; SequentialRequestMessage requestMessage = null; if (originalEnvelope.Message is SequentialRequestMessage) { requestMessage = (SequentialRequestMessage)originalEnvelope.Message; } else if (originalEnvelope.Message is RequestQuantum) { requestMessage = ((RequestQuantum)originalEnvelope.Message).RequestEnvelope.Message as SequentialRequestMessage; } if (requestMessage == null) { return(null); } return(context.AccountStorage.GetAccount(requestMessage.Account).Account.Pubkey); }
public AuditorResultsBatchHandler(AlphaContext context) : base(context) { }
public AuditLedgerManager(AlphaContext context) : base(context) { alphaListener = (AlphaTxListener)context.TxListener; Task.Factory.StartNew(TryHandleTxCommit, TaskCreationOptions.LongRunning); }
public OrderMessageHandler(AlphaContext context) : base(context) { }
public AccountDataRequestHandler(AlphaContext context) : base(context) { }
public OrderCancellationMessageHandler(AlphaContext context) : base(context) { }
public UnsubscribeCommandHandler(AlphaContext context) : base(context) { }
public PaymentMessageHandler(AlphaContext context) : base(context) { }
public ResultMessageItem(MessageEnvelope resultEnvelope, byte[] messageHash, Dictionary <int, Message> notifications, AlphaContext context) { ResultEnvelope = resultEnvelope ?? throw new ArgumentNullException(nameof(resultEnvelope)); Hash = messageHash; IsTxResultMessage = resultEnvelope.Message is ITransactionResultMessage; AccountPubKey = GetMessageAccount(context); Notifications = notifications ?? throw new ArgumentNullException(nameof(notifications)); }
public AuditorStateMessageHandler(AlphaContext context) : base(context) { }
public WithdrawalMessageHandler(AlphaContext context) : base(context) { }
public AlphaEffectsRequestMessageHandler(AlphaContext context) : base(context) { }
public AuditorPerfStatisticsMessageHandler(AlphaContext context) : base(context) { }
public GetPriceHistoryCommandHandler(AlphaContext context) : base(context) { }
protected AlphaBaseQuantumHandler(AlphaContext context) : base(context) { }