示例#1
0
        /// <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);
            }
        }
示例#2
0
 /// <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();
     }
 }
示例#3
0
        /// <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);
 }
示例#7
0
 public OrderMessageHandler(AlphaContext context)
     : base(context)
 {
 }
示例#8
0
 public AccountDataRequestHandler(AlphaContext context)
     : base(context)
 {
 }
示例#9
0
 public OrderCancellationMessageHandler(AlphaContext context) 
     : base(context)
 {
 }
 public UnsubscribeCommandHandler(AlphaContext context)
     : base(context)
 {
 }
示例#11
0
 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));
 }
示例#13
0
 public AuditorStateMessageHandler(AlphaContext context)
     : base(context)
 {
 }
 public WithdrawalMessageHandler(AlphaContext context)
     : base(context)
 {
 }
示例#15
0
 public AlphaEffectsRequestMessageHandler(AlphaContext context)
     : base(context)
 {
 }
示例#16
0
 public AuditorPerfStatisticsMessageHandler(AlphaContext context)
     : base(context)
 {
 }
 public GetPriceHistoryCommandHandler(AlphaContext context)
     : base(context)
 {
 }
示例#18
0
 protected AlphaBaseQuantumHandler(AlphaContext context)
     : base(context)
 {
 }